Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
SimpleQueue Class Reference

A simple fast single-linked stack class with non-virtual methods. More...

#include <SimpleQueue.hxx>

Inheritance diagram for SimpleQueue:
TypedQueue< Selectable > TypedQueue< Buffer > TypedQueue< ConfigUpdateListener > TypedQueue< Executable > TypedQueue< Buffer< HubContainer > > TypedQueue< openlcb::ConsistEntry > TypedQueue< T >

Classes

class  end_iterator
 Static iterator class pointing to the "end" of the queue. More...
 
class  iterator
 STL-compatible iterator for SimpleQueue. More...
 
class  typed_iterator
 STL-compatible iterator for TypedQueue. More...
 

Public Member Functions

bool empty ()
 
void push_front (QMember *member)
 Adds an entry to the front of the queue.
 
QMemberpop_front ()
 Removes the entry at the front of the queue.
 
QMemberfront () const
 peeks.
 
iterator begin ()
 
end_iterator end ()
 
void insert (const iterator &position, QMember *entry)
 Inserts the element entry before the position.
 
void erase (const iterator &position)
 Removes the entry pointed to by the iterator.
 

Protected Attributes

QMemberhead_
 Top pointer for the stack.
 

Static Protected Attributes

static QMember *const PTR_END = nullptr
 Used as a guard for comparing against for the end of the queue.
 

Detailed Description

A simple fast single-linked stack class with non-virtual methods.

This structure allows putting QMember descendants (including buffers, stateflows, exeutables etc) into a queue without incurring the overhead of the virtual methods and allocation semantics of BufferQueue.

SimpleQueue does not support asynchronous access, allocation/deallocation and notification, but supports strongly typed access (via TypedQueue) and queueing types other than Buffers. Almost all functions on SimpleQueue compile into just a few machine instructions.

Definition at line 49 of file SimpleQueue.hxx.

Constructor & Destructor Documentation

◆ SimpleQueue()

SimpleQueue::SimpleQueue ( )
inline

Definition at line 51 of file SimpleQueue.hxx.

Member Function Documentation

◆ begin()

iterator SimpleQueue::begin ( )
inline
Returns
iterator pointing to first element.

Definition at line 144 of file SimpleQueue.hxx.

◆ empty()

bool SimpleQueue::empty ( )
inline
Returns
true ofthe queue has no elements in there.

Definition at line 54 of file SimpleQueue.hxx.

◆ end()

end_iterator SimpleQueue::end ( )
inline
Returns
a sentinel to compare against for determining when an iteration is done. This sentinel cannot be used to insert entries at the end of the queue.

Definition at line 151 of file SimpleQueue.hxx.

◆ erase()

void SimpleQueue::erase ( const iterator position)
inline

Removes the entry pointed to by the iterator.

The iterator will afterwards point to the next member after the removed one (or end() if this was the last member). Invalidates any other iterator pointing just behind the marked position (but not iterators pointing elsewhere).

Parameters
positioniterator to entry to remove

Definition at line 171 of file SimpleQueue.hxx.

◆ front()

QMember * SimpleQueue::front ( ) const
inline

peeks.

Returns
the entry at the front of the queue.

Definition at line 76 of file SimpleQueue.hxx.

◆ insert()

void SimpleQueue::insert ( const iterator position,
QMember entry 
)
inline

Inserts the element entry before the position.

The iterator will point to the new member.

Parameters
positionwhich entry to insert before
entrywhat to insert before *position.

Definition at line 160 of file SimpleQueue.hxx.

◆ pop_front()

QMember * SimpleQueue::pop_front ( )
inline

Removes the entry at the front of the queue.

Returns
the entry at the front of the queue.

Definition at line 67 of file SimpleQueue.hxx.

◆ push_front()

void SimpleQueue::push_front ( QMember member)
inline

Adds an entry to the front of the queue.

Parameters
memberentry to add.

Definition at line 59 of file SimpleQueue.hxx.

Member Data Documentation

◆ head_

QMember* SimpleQueue::head_
protected

Top pointer for the stack.

Definition at line 183 of file SimpleQueue.hxx.

◆ PTR_END

QMember *const SimpleQueue::PTR_END = nullptr
staticprotected

Used as a guard for comparing against for the end of the queue.

Definition at line 180 of file SimpleQueue.hxx.


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