void FastMarch2D::FastMarch() {
	static int x, y; 
	for(int index = PopHeap(); index != -1; index = PopHeap()) {
		if(grid[index].value > FASTMARCH_LIMIT) return;
		GIJ(index, x, y);
        if(grid[GI(x-1,y)].DoneFlag == 0) FindPhi(GI(x-1,y),x-1,y);
        if(grid[GI(x+1,y)].DoneFlag == 0) FindPhi(GI(x+1,y),x+1,y);
        if(grid[GI(x,y-1)].DoneFlag == 0) FindPhi(GI(x,y-1),x,y-1);
        if(grid[GI(x,y+1)].DoneFlag == 0) FindPhi(GI(x,y+1),x,y+1);
	}
}
Ejemplo n.º 2
0
void CMemMgr::mem_free( void *p, bool bAutoHeap )
{
	if ( bAutoHeap )
	{
		// find the current heap
		m_current_freed_heap = FindHeap( p );
		assert( m_current_freed_heap >=0 && m_current_freed_heap < m_num_heaps );
		
		PushHeap(); // keep current heap
		UseHeap( m_current_freed_heap ); // switch to the owner
		mp_heaps[ m_current_heap ].mem_free( p );
		PopHeap();	// restore current heap
	}
	else
	{
		mp_heaps[ m_current_heap ].mem_free( p );
	}
}
Ejemplo n.º 3
0
int main()
{
	heap pq;
	InitHeap(&pq, comp);
	
	PushHeap(&pq, 3343, 1, 0);
	PushHeap(&pq, 13, 1, 0);
	PushHeap(&pq, 241, 1, 0);
	PushHeap(&pq, 54, 1, 0);
	PushHeap(&pq, 2324, 1, 0);
	PushHeap(&pq, 3, 1, 0);
	
	while(!EmptyHeap(&pq))
	{
		printf("%d\n", FrontHeapValue(&pq));
		PopHeap(&pq);
	}
	ClearHeap(&pq);
	return 0;
}