Rosetta Utilities  2014.35
Public Member Functions | Private Member Functions | Private Attributes | List of all members
utility::heap Class Reference

#include <heap.hh>

Public Member Functions

 heap (int max_items)
 Create a heap with this number of items. More...
 
virtual ~heap ()
 
void heap_insert (int val, float coval, bool &err)
 Inserts a value into the heap that is sorted by coval. More...
 
void heap_extract (int &val, float &coval, bool &err)
 Extracts the val,coval pair with the lowest coval from the heap. This modifies the heap, and the returned values are put into the arguments val and coval. More...
 
void heap_replace (int val, float coval)
 heap_replace More...
 
void reset_coval (int val, float coval)
 
float heap_head () const
 returns the smallest covalue stored in the heap. More...
 
float coval (int index) const
 
int val (int index) const
 
int size () const
 
int capacity () const
 
- Public Member Functions inherited from utility::pointer::ReferenceCount
void ctor ()
 
virtual ~ReferenceCount ()
 Destructor. More...
 
Size ref_count () const
 Reference count. More...
 

Private Member Functions

void heap_init (int max_items)
 sets up an empty heap and stores the dimensioned size More...
 
void heap_down (int index_in)
 heap_down More...
 
void heap_up (int index_in)
 heap_up More...
 
intheap_size ()
 
intheap_capacity ()
 
void decrease_coval (int index, float coval)
 
void increase_coval (int index, float coval)
 
int index_for_val (int val)
 

Private Attributes

utility::vector0< intheap_
 
utility::vector0< floatcoheap_
 

Additional Inherited Members

- Public Types inherited from utility::pointer::ReferenceCount
typedef platform::Size Size
 
typedef platform::Size size_type
 
- Protected Member Functions inherited from utility::pointer::ReferenceCount
 ReferenceCount ()
 Default constructor. More...
 
 ReferenceCount (ReferenceCount const &)
 Copy constructor. More...
 
ReferenceCountoperator= (ReferenceCount const &)
 Copy assignment. More...
 

Constructor & Destructor Documentation

utility::heap::heap ( int  max_items)
inline

Create a heap with this number of items.

References coheap_, heap_, and heap_init().

utility::heap::~heap ( )
virtual

Member Function Documentation

int utility::heap::capacity ( ) const

References heap_.

float utility::heap::coval ( int  index) const
void utility::heap::decrease_coval ( int  index,
float  coval 
)
private

References coheap_, coval(), and heap_up().

Referenced by reset_coval().

int & utility::heap::heap_capacity ( )
private

References heap_.

Referenced by heap_init(), and heap_insert().

void utility::heap::heap_down ( int  index_in)
private

heap_down

References coheap_, heap_, and heap_size().

Referenced by heap_extract(), heap_replace(), and increase_coval().

void utility::heap::heap_extract ( int val,
float coval,
bool err 
)

Extracts the val,coval pair with the lowest coval from the heap. This modifies the heap, and the returned values are put into the arguments val and coval.

modifes heap and last_val return val and err.

heap_extract

References coheap_, heap_, heap_down(), and heap_size().

float utility::heap::heap_head ( ) const

returns the smallest covalue stored in the heap.

References coheap_.

void utility::heap::heap_init ( int  max_items)
private

sets up an empty heap and stores the dimensioned size

heap_init

References heap_capacity(), and heap_size().

Referenced by heap().

void utility::heap::heap_insert ( int  val,
float  coval,
bool err 
)

Inserts a value into the heap that is sorted by coval.

modifies heap and last_dummy, inserts val, returns err requires heap_max to be previously set via heap_init

heap_insert

References coheap_, coval(), heap_, heap_capacity(), heap_replace(), heap_size(), heap_up(), and val().

void utility::heap::heap_replace ( int  val,
float  coval 
)

heap_replace

References coheap_, coval(), heap_, heap_down(), and val().

Referenced by heap_insert().

int & utility::heap::heap_size ( )
private
void utility::heap::heap_up ( int  index_in)
private

heap_up

References coheap_, heap_, and value.

Referenced by decrease_coval(), and heap_insert().

void utility::heap::increase_coval ( int  index,
float  coval 
)
private

References coheap_, coval(), and heap_down().

Referenced by reset_coval().

int utility::heap::index_for_val ( int  val)
private

References heap_, and heap_size().

Referenced by reset_coval().

void utility::heap::reset_coval ( int  val,
float  coval 
)
int utility::heap::size ( ) const

References heap_.

int utility::heap::val ( int  index) const

References heap_.

Referenced by heap_insert(), and heap_replace().

Member Data Documentation

utility::vector0< float > utility::heap::coheap_
private
utility::vector0< int > utility::heap::heap_
private

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