![]() |
Rosetta Utilities
2014.35
|
A class for keeping track of a subset of elements in a set that are pushed into a queue in a certain order, and which fall off the end of the queue in ther order in which they arrive. Elements in the set can be bumped to the front of the queue. More...
#include <recent_history_queue.hh>
Public Member Functions | |
recent_history_queue () | |
recent_history_queue (int num_elements, int history_size) | |
virtual | ~recent_history_queue () |
void | clear () |
void | num_elements (int num_elements) |
void | history_size (int history_size) |
int | num_elements () const |
int | history_size () const |
int | curr_num_in_recent_history () const |
int | head_of_queue () const |
For unit-testing purposes. More... | |
int | end_of_queue () const |
For unit-testing purposes. More... | |
int | pos_in_history_queue (int element) const |
Returns the position in the recent history for a given element in the set. Returns 0 if the element is not part of the recent history. More... | |
int | push_to_front_of_history_queue (int element) |
Push an element to the front of the recent history queue. This will likely bump an element that had been in the recent history queue; in that event, this function returns the in-place index for that bumped element. If the new element doesn't displace some other element (i.e. if the queue is either not yet full, or if the element was already in the queue), then this function returns a fictional index of "0". More... | |
unsigned int | dynamic_memory_usage () const |
![]() | |
void | ctor () |
virtual | ~ReferenceCount () |
Destructor. More... | |
Size | ref_count () const |
Reference count. More... | |
Additional Inherited Members | |
![]() | |
typedef platform::Size | Size |
typedef platform::Size | size_type |
![]() | |
ReferenceCount () | |
Default constructor. More... | |
ReferenceCount (ReferenceCount const &) | |
Copy constructor. More... | |
ReferenceCount & | operator= (ReferenceCount const &) |
Copy assignment. More... | |
A class for keeping track of a subset of elements in a set that are pushed into a queue in a certain order, and which fall off the end of the queue in ther order in which they arrive. Elements in the set can be bumped to the front of the queue.
The queue is "in place", so there are no calls to new or delete with repeated calls to push_to_front_of_history_queue().
The position in queue can be used to keep track of data for elements, where the position is understood not as the number of elements between the element and the front of the queue, but rather, an index that the object has in the "recent_history_queue_" data member – an array. If an element is in the queue with index X, and then it is pushed to the front of the history queue, its index will still be X.
utility::recent_history_queue::recent_history_queue | ( | ) |
|
virtual |
void utility::recent_history_queue::clear | ( | ) |
References curr_num_in_recent_history_, utility::history_queue_struct::element_in_rh, elements_2_recent_history_, end_of_rh_queue_ptr_, head_of_rh_queue_ptr_, history_size_, utility::history_queue_struct::more_ancient_ptr, utility::history_queue_struct::more_recent_ptr, num_elements_, recent_history_queue_, and numeric::constants::f::zero.
Referenced by history_size(), and num_elements().
int utility::recent_history_queue::curr_num_in_recent_history | ( | ) | const |
References curr_num_in_recent_history_.
unsigned int utility::recent_history_queue::dynamic_memory_usage | ( | ) | const |
References elements_2_recent_history_, and recent_history_queue_.
int utility::recent_history_queue::end_of_queue | ( | ) | const |
For unit-testing purposes.
References end_of_rh_queue_ptr_.
int utility::recent_history_queue::head_of_queue | ( | ) | const |
For unit-testing purposes.
References head_of_rh_queue_ptr_.
void utility::recent_history_queue::history_size | ( | int | history_size | ) |
References clear(), history_size(), history_size_, and recent_history_queue_.
int utility::recent_history_queue::history_size | ( | ) | const |
References history_size_.
Referenced by history_size().
void utility::recent_history_queue::num_elements | ( | int | num_elements | ) |
References clear(), elements_2_recent_history_, num_elements(), and num_elements_.
int utility::recent_history_queue::num_elements | ( | ) | const |
References num_elements_.
Referenced by num_elements().
Returns the position in the recent history for a given element in the set. Returns 0 if the element is not part of the recent history.
References elements_2_recent_history_.
Push an element to the front of the recent history queue. This will likely bump an element that had been in the recent history queue; in that event, this function returns the in-place index for that bumped element. If the new element doesn't displace some other element (i.e. if the queue is either not yet full, or if the element was already in the queue), then this function returns a fictional index of "0".
References curr_num_in_recent_history_, elements_2_recent_history_, end_of_rh_queue_ptr_, head_of_rh_queue_ptr_, history_size_, and recent_history_queue_.
|
private |
Referenced by clear(), curr_num_in_recent_history(), and push_to_front_of_history_queue().
|
private |
Referenced by clear(), dynamic_memory_usage(), num_elements(), pos_in_history_queue(), and push_to_front_of_history_queue().
|
private |
Referenced by clear(), end_of_queue(), and push_to_front_of_history_queue().
|
private |
Referenced by clear(), head_of_queue(), and push_to_front_of_history_queue().
|
private |
Referenced by clear(), history_size(), push_to_front_of_history_queue(), and recent_history_queue().
|
private |
Referenced by clear(), and num_elements().
|
private |
Referenced by clear(), dynamic_memory_usage(), history_size(), push_to_front_of_history_queue(), and recent_history_queue().