FreeNOS
Public Member Functions | Private Attributes
Queue< T, N > Class Template Reference

Array of items as a First-In-First-Out (FIFO) datastructure. More...

#include <Queue.h>

Inheritance diagram for Queue< T, N >:
Container

Public Member Functions

 Queue ()
 Default constructor. More...
 
bool push (const T &item)
 Add item to the head of the Queue. More...
 
T & pop ()
 Remove item from the tail of the Queue. More...
 
bool contains (const T &item) const
 Look if an item exists on the Queue. More...
 
Size remove (T value)
 Remove all items with the given value. More...
 
virtual void clear ()
 Removes all items from the Queue. More...
 
virtual Size size () const
 Returns the maximum size of this Queue. More...
 
virtual Size count () const
 Returns the number of items in the Queue. More...
 
- Public Member Functions inherited from Container
 Container ()
 Constructor. More...
 
virtual ~Container ()
 Destructor. More...
 
virtual bool isEmpty () const
 Check if the Container is empty. More...
 
virtual bool reserve (Size size)
 Ensure that at least the given size is available. More...
 
virtual bool shrink (Size size)
 Shrink the container size by the given amount of items. More...
 
virtual Size squeeze ()
 Try to minimize the memory required in the Container. More...
 
virtual bool resize (Size size)
 Change the size of the Container. More...
 

Private Attributes

m_array [N]
 The actual array where the data is stored. More...
 
uint m_head
 Head of the queue. More...
 
uint m_tail
 Tail of the queue. More...
 
uint m_count
 Number of items in the queue. More...
 

Detailed Description

template<class T, Size N>
class Queue< T, N >

Array of items as a First-In-First-Out (FIFO) datastructure.

Definition at line 36 of file Queue.h.

Constructor & Destructor Documentation

◆ Queue()

template<class T , Size N>
Queue< T, N >::Queue ( )
inline

Default constructor.

Definition at line 43 of file Queue.h.

Member Function Documentation

◆ clear()

template<class T , Size N>
virtual void Queue< T, N >::clear ( )
inlinevirtual

Removes all items from the Queue.

Implements Container.

Definition at line 131 of file Queue.h.

Referenced by Queue< NetworkQueue::Packet *, NetworkQueue::MaxPackets >::Queue().

◆ contains()

template<class T , Size N>
bool Queue< T, N >::contains ( const T &  item) const
inline

Look if an item exists on the Queue.

Parameters
itemItem reference
Returns
True if the item exists, false otherwise

Definition at line 92 of file Queue.h.

Referenced by ProcessManager::sleep().

◆ count()

template<class T , Size N>
virtual Size Queue< T, N >::count ( ) const
inlinevirtual

Returns the number of items in the Queue.

Returns
Number of items in the Queue.

Implements Container.

Definition at line 153 of file Queue.h.

Referenced by Scheduler::count(), Scheduler::dequeue(), Sun8iEmac::interrupt(), ProcessManager::schedule(), Scheduler::select(), Sun8iEmac::startDMA(), and Sun8iEmac::transmit().

◆ pop()

template<class T , Size N>
T& Queue< T, N >::pop ( )
inline

Remove item from the tail of the Queue.

Returns
Item T
Note
Do not call this function if the Queue is empty

Definition at line 76 of file Queue.h.

Referenced by Scheduler::dequeue(), Sun8iEmac::interrupt(), Queue< NetworkQueue::Packet *, NetworkQueue::MaxPackets >::remove(), ProcessManager::schedule(), Scheduler::select(), and Sun8iEmac::startDMA().

◆ push()

template<class T , Size N>
bool Queue< T, N >::push ( const T &  item)
inline

Add item to the head of the Queue.

Parameters
itemThe item to add
Returns
True if successful, false otherwise

Definition at line 55 of file Queue.h.

Referenced by Scheduler::dequeue(), Scheduler::enqueue(), Queue< NetworkQueue::Packet *, NetworkQueue::MaxPackets >::remove(), ProcessManager::schedule(), Scheduler::select(), ProcessManager::sleep(), Sun8iEmac::startDMA(), and Sun8iEmac::transmit().

◆ remove()

template<class T , Size N>
Size Queue< T, N >::remove ( value)
inline

Remove all items with the given value.

Parameters
valueValue to remove.
Returns
Number of items removed.

Definition at line 110 of file Queue.h.

Referenced by ProcessManager::enqueueProcess(), and ProcessManager::remove().

◆ size()

template<class T , Size N>
virtual Size Queue< T, N >::size ( ) const
inlinevirtual

Returns the maximum size of this Queue.

Returns
size The maximum size of the Queue.

Implements Container.

Definition at line 143 of file Queue.h.

Field Documentation

◆ m_array

template<class T , Size N>
T Queue< T, N >::m_array[N]
private

◆ m_count

template<class T , Size N>
uint Queue< T, N >::m_count
private

◆ m_head

template<class T , Size N>
uint Queue< T, N >::m_head
private

◆ m_tail

template<class T , Size N>
uint Queue< T, N >::m_tail
private

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