[Xorp-cvs] XORP cvs commit: xorp/libxorp
Atanu Ghosh
atanu@icir.org
Fri, 27 May 2005 20:01:01 GMT
CVSROOT: /usr/local/www/data/cvs
Module name: xorp
Changes by: atanu@xorpc.icir.org 2005-05-27 20:01:01 UTC
XORP CVS repository
Modified files:
libxorp heap.cc heap.hh test_heap.cc timer.cc timer.hh
Log message:
The heap code allows a set of objects to be held as a priority
queue. The timer code uses the heap code. The heap code itself holds
little chunks of data (heap_entry) which it holds in a contiguous block
of memory. The heap_entry holds a key and a pointer to the object. When
an entry is added it is placed at the end of the heap and is bubbled
into position. The most recent entry is at the head of the list. If a an
entry is to be removed from the heap then it would necessary to search
the whole heap for it, but wait, the heap can be configured to hold an
index into the heap in the object itself cool.
Both on the MIPS and Sparc the casts required to update the object
itself have been causing problems. They require casting a void * to a
char * in order to perform the arithmetic and then casting to an int *
to do the update. Pavlin points out that an extra void * cast between
the char * and int * solves the problem.
Introduce a HeapBase, objects that are to be stored on the heap
can inherit from it if they require removal from arbitary
positions.
Approved by: Pavlin
Revision Changes Path
1.12 +16 -16; commitid: 162642977c7c7ea6; xorp/libxorp/heap.cc
1.8 +26 -20; commitid: 162642977c7c7ea6; xorp/libxorp/heap.hh
1.3 +16 -11; commitid: 162642977c7c7ea6; xorp/libxorp/test_heap.cc
1.22 +5 -5; commitid: 162642977c7c7ea6; xorp/libxorp/timer.cc
1.22 +2 -3; commitid: 162642977c7c7ea6; xorp/libxorp/timer.hh