Biomedical Image Analysis Library
The Biomedical Image Analysis Library is a poweful tool for developers, physicians, researchers, engineers, and so on.
Bial::RandomQueue Class Reference

A random-acess queue. Its size is fixed. As soon as it gets full, the first inserted element is automatically replaced by the next inserted element.
It is useful to find the median element as walking through signal or image data, e.g. MedianFilter method of Signal class. Insertion and removal are made in limiar time with respect to the queue size.
Access to ordered keys by position is made in constant time. More...

#include <RandomQueue.hpp>

Collaboration diagram for Bial::RandomQueue:
Collaboration graph

Public Member Functions

 RandomQueue (size_t size, bool increasing_order=true)
 Basic Constructor. More...
 
double operator[] (size_t elm) const
 Returns key at the elm-th position in increasing or decreasing order, e.g., if elm = 0 and increasing is true, then the smallest key is returned. More...
 
size_t Size () const
 Returns the current size of the queue. More...
 
size_t Capacity () const
 Returns the maximum capacity of the queue. More...
 
void Insert (double key)
 Inserts the input key into the random queue. If the queue is full, then the new key will automatically replace the oldest key in the queue. More...
 
double Remove ()
 Removes and returns the oldest key in the queue. More...
 
void Update (double key, double new_key)
 Updates the input key with new_key value. If there is more than one key with the expected value, then one of them (randomly chosen) will updated. More...
 
double Minimum () const
 Returns the minimum key in the queue. If the number of keys is even, then the mean value of the two minimum keys is returned. More...
 
double Median () const
 Returns the median key in the queue. If the number of keys is even, then the mean value of the two median keys is returned. More...
 
double Maximum () const
 Returns the maximum key in the queue. If the number of keys is even, then the mean value of the two maximum keys is returned. More...
 
bool Full ()
 Returns true, if random queue is completely filled. More...
 
bool Empty ()
 Returns true, if random queue is empty. More...
 
template<class O >
void Print (O &os)
 Prints random queue current keys. More...
 

Protected Attributes

Vector< double > _data
 
Vector< size_t > order
 
double * qk_data
 
size_t occupancy
 
size_t last
 
bool increasing
 

Detailed Description

A random-acess queue. Its size is fixed. As soon as it gets full, the first inserted element is automatically replaced by the next inserted element.
It is useful to find the median element as walking through signal or image data, e.g. MedianFilter method of Signal class. Insertion and removal are made in limiar time with respect to the queue size.
Access to ordered keys by position is made in constant time.

Definition at line 38 of file RandomQueue.hpp.

Constructor & Destructor Documentation

Bial::RandomQueue::RandomQueue ( size_t  size,
bool  increasing_order = true 
)

Basic Constructor.

Date
2012/Sep/12
Parameters
sizemaximum capacity of the queue.
increasing_orderincreasing or decreasing order of random queue elements sorting.
Returns
none.
Warning
none.

Member Function Documentation

size_t Bial::RandomQueue::Capacity ( ) const

Returns the maximum capacity of the queue.

Date
2012/Sep/12
Parameters
none.
Returns
The maximum capacity of the queue.
Warning
none.
bool Bial::RandomQueue::Empty ( )

Returns true, if random queue is empty.

Date
2012/Sep/13
Parameters
none.
Returns
True, if random queue is empty.
Warning
none.
bool Bial::RandomQueue::Full ( )

Returns true, if random queue is completely filled.

Date
2012/Sep/12
Parameters
none.
Returns
True, if random queue is completely filled.
Warning
none.
void Bial::RandomQueue::Insert ( double  key)

Inserts the input key into the random queue. If the queue is full, then the new key will automatically replace the oldest key in the queue.

Date
2012/Sep/12
Parameters
keyA key.
Returns
none.
Warning
none.
double Bial::RandomQueue::Maximum ( ) const

Returns the maximum key in the queue. If the number of keys is even, then the mean value of the two maximum keys is returned.

Date
2012/Sep/12
Parameters
none.
Returns
The maximum key in the queue.
Warning
Queue occupancy is not verified.
double Bial::RandomQueue::Median ( ) const

Returns the median key in the queue. If the number of keys is even, then the mean value of the two median keys is returned.

Date
2012/Sep/12
Parameters
none.
Returns
The median key in the queue.
Warning
Queue occupancy is not verified.
double Bial::RandomQueue::Minimum ( ) const

Returns the minimum key in the queue. If the number of keys is even, then the mean value of the two minimum keys is returned.

Date
2012/Sep/12
Parameters
none.
Returns
The minimum key in the queue.
Warning
Queue occupancy is not verified.
double Bial::RandomQueue::operator[] ( size_t  elm) const

Returns key at the elm-th position in increasing or decreasing order, e.g., if elm = 0 and increasing is true, then the smallest key is returned.

Date
2012/Sep/12
Parameters
elmA sorted index.
Returns
Key at the p-th position.
Warning
Queue bounds are not verified.
template<class O >
void Bial::RandomQueue::Print ( O &  os)

Prints random queue current keys.

Date
2012/Sep/12
Parameters
osan output stream.
Returns
none.
Warning
none.

Definition at line 185 of file RandomQueue.hpp.

double Bial::RandomQueue::Remove ( )

Removes and returns the oldest key in the queue.

Date
2012/Sep/12
Parameters
none.
Returns
The removed key.
Warning
none.
size_t Bial::RandomQueue::Size ( ) const

Returns the current size of the queue.

Date
2012/Sep/12
Parameters
none.
Returns
The current size of the queue.
Warning
none.
void Bial::RandomQueue::Update ( double  key,
double  new_key 
)

Updates the input key with new_key value. If there is more than one key with the expected value, then one of them (randomly chosen) will updated.

Date
2012/Sep/12
Parameters
keyA key.
new_keyThe new value to be assigned to key.
Returns
none.
Warning
none.

Member Data Documentation

Vector< double > Bial::RandomQueue::_data
protected

Definition at line 41 of file RandomQueue.hpp.

bool Bial::RandomQueue::increasing
protected

Definition at line 46 of file RandomQueue.hpp.

size_t Bial::RandomQueue::last
protected

Definition at line 45 of file RandomQueue.hpp.

size_t Bial::RandomQueue::occupancy
protected

Definition at line 44 of file RandomQueue.hpp.

Vector< size_t > Bial::RandomQueue::order
protected

Definition at line 42 of file RandomQueue.hpp.

double* Bial::RandomQueue::qk_data
protected

Definition at line 43 of file RandomQueue.hpp.


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