Blender V2.61 - r43446
Classes | Defines | Functions

BLI_heap.c File Reference

#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_memarena.h"
#include "BLI_heap.h"

Go to the source code of this file.

Classes

struct  HeapNode
struct  Heap

Defines

#define SWAP(type, a, b)   { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
#define HEAP_PARENT(i)   ((i-1)>>1)
#define HEAP_LEFT(i)   ((i<<1)+1)
#define HEAP_RIGHT(i)   ((i<<1)+2)
#define HEAP_COMPARE(a, b)   (a->value < b->value)
#define HEAP_EQUALS(a, b)   (a->value == b->value)
#define HEAP_SWAP(heap, i, j)

Functions

HeapBLI_heap_new (void)
void BLI_heap_free (Heap *heap, HeapFreeFP ptrfreefp)
static void BLI_heap_down (Heap *heap, int i)
static void BLI_heap_up (Heap *heap, int i)
HeapNodeBLI_heap_insert (Heap *heap, float value, void *ptr)
int BLI_heap_empty (Heap *heap)
int BLI_heap_size (Heap *heap)
HeapNodeBLI_heap_top (Heap *heap)
void * BLI_heap_popmin (Heap *heap)
void BLI_heap_remove (Heap *heap, HeapNode *node)
float BLI_heap_node_value (HeapNode *node)
void * BLI_heap_node_ptr (HeapNode *node)

Detailed Description

Definition in file BLI_heap.c.


Define Documentation

#define HEAP_COMPARE (   a,
 
)    (a->value < b->value)

Definition at line 62 of file BLI_heap.c.

Referenced by BLI_heap_down(), and BLI_heap_up().

#define HEAP_EQUALS (   a,
 
)    (a->value == b->value)

Definition at line 63 of file BLI_heap.c.

#define HEAP_LEFT (   i)    ((i<<1)+1)

Definition at line 60 of file BLI_heap.c.

Referenced by BLI_heap_down().

#define HEAP_PARENT (   i)    ((i-1)>>1)

Definition at line 59 of file BLI_heap.c.

Referenced by BLI_heap_remove(), and BLI_heap_up().

#define HEAP_RIGHT (   i)    ((i<<1)+2)

Definition at line 61 of file BLI_heap.c.

Referenced by BLI_heap_down().

#define HEAP_SWAP (   heap,
  i,
 
)
Value:
{                                                                             \
    SWAP(int, heap->tree[i]->index, heap->tree[j]->index);                    \
    SWAP(HeapNode*, heap->tree[i], heap->tree[j]);                            \
}

Definition at line 64 of file BLI_heap.c.

Referenced by BLI_heap_down(), BLI_heap_popmin(), BLI_heap_remove(), and BLI_heap_up().

#define SWAP (   type,
  a,
 
)    { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }

Definition at line 57 of file BLI_heap.c.


Function Documentation

static void BLI_heap_down ( Heap heap,
int  i 
) [static]

Definition at line 95 of file BLI_heap.c.

References HEAP_COMPARE, HEAP_LEFT, HEAP_RIGHT, HEAP_SWAP, Heap::size, size(), and Heap::tree.

Referenced by BLI_heap_popmin().

int BLI_heap_empty ( Heap heap)

Definition at line 164 of file BLI_heap.c.

References Heap::size.

Referenced by edgetag_shortest_path(), and select_vertex_path_exec().

void BLI_heap_free ( Heap heap,
HeapFreeFP  ptrfreefp 
)
HeapNode* BLI_heap_insert ( Heap heap,
float  value,
void *  ptr 
)
Heap* BLI_heap_new ( void  )
void* BLI_heap_node_ptr ( HeapNode node)

Definition at line 217 of file BLI_heap.c.

References HeapNode::ptr.

float BLI_heap_node_value ( HeapNode node)

Definition at line 212 of file BLI_heap.c.

References HeapNode::value.

Referenced by shortestPathsFromVert().

void* BLI_heap_popmin ( Heap heap)
void BLI_heap_remove ( Heap heap,
HeapNode node 
)

Definition at line 198 of file BLI_heap.c.

References BLI_heap_popmin(), HEAP_PARENT, HEAP_SWAP, i, HeapNode::index, and p.

Referenced by p_chart_fill_boundary().

int BLI_heap_size ( Heap heap)

Definition at line 169 of file BLI_heap.c.

References Heap::size.

Referenced by shortestPathsFromVert().

HeapNode* BLI_heap_top ( Heap heap)

Definition at line 174 of file BLI_heap.c.

References Heap::tree.

Referenced by shortestPathsFromVert().

static void BLI_heap_up ( Heap heap,
int  i 
) [static]

Definition at line 115 of file BLI_heap.c.

References HEAP_COMPARE, HEAP_PARENT, HEAP_SWAP, p, and Heap::tree.

Referenced by BLI_heap_insert().