Interface: tos.interfaces.Queue

interface Queue<typedef t>

Interface to a FIFO list (queue) that contains items of a specific type. The queue has a maximum size.

Author:
Philip Levis
Kyle Jamieson
Date:
$Date: 2008/06/04 03:00:31 $

Commands
command t dequeue() Remove the head of the queue.
command t element(uint8_t idx) Return the nth element of the queue without dequeueing it, where 0 is the head of the queue and (size - 1) is the tail.
command bool empty() Returns if the queue is empty.
command error_t enqueue(t newVal) Enqueue an element to the tail of the queue.
command t head() Get the head of the queue without removing it.
command uint8_t maxSize() The maximum number of elements the queue can hold.
command uint8_t size() The number of elements currently in the queue.

Commands - Details

dequeue

command t dequeue()

Remove the head of the queue. If the queue is empty, the return value is undefined.

Returns:
't ONE' The head of the queue.

element

command t element(uint8_t idx)

Return the nth element of the queue without dequeueing it, where 0 is the head of the queue and (size - 1) is the tail. If the element requested is larger than the current queue size, the return value is undefined.

Parameters:
index - - the index of the element to return
Returns:
't ONE' the requested element in the queue.

empty

command bool empty()

Returns if the queue is empty.

Returns:
Whether the queue is empty.

enqueue

command error_t enqueue(t newVal)

Enqueue an element to the tail of the queue.

Parameters:
't ONE newVal' - the element to enqueue
Returns:
SUCCESS if the element was enqueued successfully, FAIL if it was not enqueued.

head

command t head()

Get the head of the queue without removing it. If the queue is empty, the return value is undefined.

Returns:
't ONE' The head of the queue.

maxSize

command uint8_t maxSize()

The maximum number of elements the queue can hold.

Returns:
The maximum queue size.

size

command uint8_t size()

The number of elements currently in the queue. Always less than or equal to maxSize().

Returns:
The number of elements in the queue.