Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
utility::recent_history_queue Class Reference

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>

Inheritance diagram for utility::recent_history_queue:
Inheritance graph
[legend]

Public Member Functions

 recent_history_queue ()
 
 recent_history_queue (int num_elements, int history_size)
 
 ~recent_history_queue () override
 
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
 
- Public Member Functions inherited from utility::VirtualBase
 VirtualBase ()=default
 Default constructor. More...
 
virtual ~VirtualBase ()=default
 The virtual destructor is one of the main reasons for the VirtualBase class. More...
 
 VirtualBase (VirtualBase const &)=default
 
 VirtualBase (VirtualBase &&)=default
 
VirtualBaseoperator= (VirtualBase const &)=default
 
VirtualBaseoperator= (VirtualBase &&)=default
 

Private Attributes

int num_elements_
 
int history_size_
 
int curr_num_in_recent_history_
 
utility::vector1
< history_queue_struct
recent_history_queue_
 
int head_of_rh_queue_ptr_
 
int end_of_rh_queue_ptr_
 
utility::vector1< intelements_2_recent_history_
 

Detailed Description

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.

Constructor & Destructor Documentation

utility::recent_history_queue::recent_history_queue ( )
utility::recent_history_queue::recent_history_queue ( int  num_elements,
int  history_size 
)
utility::recent_history_queue::~recent_history_queue ( )
overridedefault

Member Function Documentation

void utility::recent_history_queue::clear ( )
int utility::recent_history_queue::curr_num_in_recent_history ( ) const
unsigned int utility::recent_history_queue::dynamic_memory_usage ( ) const
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)
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)
int utility::recent_history_queue::num_elements ( ) const

References num_elements_.

Referenced by num_elements().

int utility::recent_history_queue::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.

References elements_2_recent_history_.

int utility::recent_history_queue::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".

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_.

Member Data Documentation

int utility::recent_history_queue::curr_num_in_recent_history_
private
utility::vector1< int > utility::recent_history_queue::elements_2_recent_history_
private
int utility::recent_history_queue::end_of_rh_queue_ptr_
private
int utility::recent_history_queue::head_of_rh_queue_ptr_
private
int utility::recent_history_queue::history_size_
private
int utility::recent_history_queue::num_elements_
private

Referenced by clear(), and num_elements().

utility::vector1< history_queue_struct > utility::recent_history_queue::recent_history_queue_
private

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