TPIE

2362a60
tpie::ami::merge_heap_ptr_obj< REC, CMPR > Class Template Reference

A record pointer heap that uses a comparison object. More...

#include <tpie/mergeheap.h>

Inherits tpie::ami::merge_heap_ptr_op< REC, CMPR >.

Public Member Functions

 merge_heap_ptr_obj (CMPR *cmptr)
 
size_t sizeofheap ()
 Reports the size of Heap (number of elements). More...
 
size_t get_min_run_id ()
 Returns the run with the minimum key. More...
 
void allocate (size_t size)
 Allocates space for the heap. More...
 
void insert (const REC *ptr, size_t run_id)
 Copies an (initial) element into the heap array. More...
 
void extract_min (REC &el, size_t &run_id)
 Extracts minimum element from heap array. More...
 
void deallocate ()
 Deallocates the space used by the heap. More...
 
void initialize ()
 Heapifies an initial array of elements;. More...
 
void delete_min_and_insert (const REC *nextelement_same_run)
 
size_t space_per_item ()
 Returns the main memory space usage per item. More...
 
size_t space_overhead ()
 Returns the fixed main memory space overhead, regardless of item count. More...
 

Detailed Description

template<class REC, class CMPR>
class tpie::ami::merge_heap_ptr_obj< REC, CMPR >

A record pointer heap that uses a comparison object.

Definition at line 141 of file mergeheap.h.

Member Function Documentation

void tpie::ami::merge_heap_ptr_op< REC, CMPR >::allocate ( size_t  size)
inlineinherited

Allocates space for the heap.

Definition at line 87 of file mergeheap.h.

Referenced by tpie::ami::ptr_merge_sorted().

87 {pq.resize(size);}
void tpie::ami::merge_heap_ptr_op< REC, CMPR >::deallocate ( void  )
inlineinherited

Deallocates the space used by the heap.

Definition at line 108 of file mergeheap.h.

108 {pq.resize(0);}
void tpie::ami::merge_heap_ptr_op< REC, CMPR >::extract_min ( REC &  el,
size_t &  run_id 
)
inlineinherited

Extracts minimum element from heap array.

If you follow this with an immediate insert, consider using delete_min_and_insert().

Definition at line 99 of file mergeheap.h.

99  {
100  el=*pq.top().ptr;
101  run_id=*pq.top().run_id();
102  pq.pop();
103  }
size_t tpie::ami::merge_heap_ptr_op< REC, CMPR >::get_min_run_id ( )
inlineinherited

Returns the run with the minimum key.

Definition at line 82 of file mergeheap.h.

82 {return pq.top().run_id;}
void tpie::ami::merge_heap_ptr_op< REC, CMPR >::initialize ( void  )
inlineinherited

Heapifies an initial array of elements;.

Definition at line 113 of file mergeheap.h.

113 {pq.make_safe(); }
void tpie::ami::merge_heap_ptr_op< REC, CMPR >::insert ( const REC *  ptr,
size_t  run_id 
)
inlineinherited

Copies an (initial) element into the heap array.

Definition at line 92 of file mergeheap.h.

92 {pq.unsafe_push(heap_ptr<REC>(ptr, run_id) );}
size_t tpie::ami::merge_heap_ptr_op< REC, CMPR >::sizeofheap ( )
inlineinherited

Reports the size of Heap (number of elements).

Definition at line 77 of file mergeheap.h.

77 {return pq.size();}
size_t tpie::ami::merge_heap_ptr_op< REC, CMPR >::space_overhead ( void  )
inlineinherited

Returns the fixed main memory space overhead, regardless of item count.

Definition at line 134 of file mergeheap.h.

134 { return static_cast<size_t>(pq.memory_overhead()); }
size_t tpie::ami::merge_heap_ptr_op< REC, CMPR >::space_per_item ( void  )
inlineinherited

Returns the main memory space usage per item.

Definition at line 129 of file mergeheap.h.

129 { return static_cast<size_t>(pq.memory_coefficient()); }

The documentation for this class was generated from the following file: