GHS
Leader Election Based on GHS Minimum Spanning Tree
Public Member Functions | List of all members
seque::StaticQueue< T, N > Class Template Reference

a static-sized single-ended queue for use in GhsState More...

#include <static_queue.h>

Public Member Functions

 StaticQueue ()
 
bool is_full () const
 
bool is_empty () const
 
unsigned int size () const
 
le::Errno front (T &out_item) const
 
le::Errno pop ()
 
le::Errno pop (T &out_item)
 
le::Errno push (const T item)
 
le::Errno at (const unsigned int idx, T &out_item) const
 
le::Errno clear ()
 

Detailed Description

template<typename T, unsigned int N>
class seque::StaticQueue< T, N >

a static-sized single-ended queue for use in GhsState

The StaticQueue class is a statically-sized, single-ended queue based on a cirlce buffer that is used to present and queue messags for the GhsState class

Parameters
Ta typename of the object to store
Nthe number of elements to allocat storage for

Constructor & Destructor Documentation

◆ StaticQueue()

template<typename T , unsigned int N>
StaticQueue::StaticQueue ( )

Constructs with static-sizing a circle-buf-backed queue

Member Function Documentation

◆ at()

template<typename T , unsigned int N>
le::Errno StaticQueue::at ( const unsigned int  idx,
T &  out_item 
) const

returns (symantically) the element at front()+idx, such that if idx==0, front() is returned. If idx==N, the back is returned.

Returns ERR_BAD_IDX if idx>N Returns ERR_NO_SUCH_ELEMENT if idx>size()

In any error condition, out_item is not changed.

◆ front()

template<typename T , unsigned int N>
le::Errno StaticQueue::front ( T &  out_item) const

Sets the given reference to be identical to the front of the queue, but does not alter the elements of the queue in any way

In any error condition, out_item is not changed.

◆ is_empty()

template<typename T , unsigned int N>
bool StaticQueue::is_empty ( ) const

Returns true if size()==0, and no more elements can be pop()'d or checked via front()

◆ is_full()

template<typename T , unsigned int N>
bool StaticQueue::is_full ( ) const

Returns true if size()==N, and no more elements can be push()'d

◆ pop() [1/2]

template<typename T , unsigned int N>
le::Errno StaticQueue::pop ( )

Removes the front of the queue, reducing size by 1. No memory is recovered, but the element is irretreivable after this operation.

◆ pop() [2/2]

template<typename T , unsigned int N>
le::Errno StaticQueue::pop ( T &  out_item)

This convenience function is identical to:

T item;
front(T);
pop();
return T;

It will return an error if either front() or pop() would. In any error condition, out_item is not changed.

◆ push()

template<typename T , unsigned int N>
le::Errno StaticQueue::push ( const T  item)

emplaces an element at the back of the queue. no memory is allocated.

Fails if size()==N (the static templated size)

◆ size()

template<typename T , unsigned int N>
unsigned int StaticQueue::size ( ) const

Returns the current number of elements in the queue


The documentation for this class was generated from the following files:
seque::StaticQueue::pop
le::Errno pop()
Definition: static_queue_impl.hpp:96
seque::StaticQueue::front
le::Errno front(T &out_item) const
Definition: static_queue_impl.hpp:91