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>
|
| 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...
|
|
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.
Bial::RandomQueue::RandomQueue |
( |
size_t |
size, |
|
|
bool |
increasing_order = true |
|
) |
| |
Basic Constructor.
- Date
- 2012/Sep/12
- Parameters
-
size | maximum capacity of the queue. |
increasing_order | increasing or decreasing order of random queue elements sorting. |
- Returns
- none.
- Warning
- none.
size_t Bial::RandomQueue::Capacity |
( |
| ) |
const |
Returns the maximum capacity of the queue.
- Date
- 2012/Sep/12
- Parameters
-
- 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
-
- 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
-
- 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
-
- 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
-
- 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
-
- 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
-
- 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
-
- 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
-
- 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
-
- Returns
- The removed key.
- Warning
- none.
size_t Bial::RandomQueue::Size |
( |
| ) |
const |
Returns the current size of the queue.
- Date
- 2012/Sep/12
- Parameters
-
- 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
-
key | A key. |
new_key | The new value to be assigned to key. |
- Returns
- none.
- Warning
- none.
Vector< double > Bial::RandomQueue::_data |
|
protected |
bool Bial::RandomQueue::increasing |
|
protected |
size_t Bial::RandomQueue::last |
|
protected |
size_t Bial::RandomQueue::occupancy |
|
protected |
Vector< size_t > Bial::RandomQueue::order |
|
protected |
double* Bial::RandomQueue::qk_data |
|
protected |
The documentation for this class was generated from the following file: