Installation

In the Arduino IDE, create a new sketch and select from the menubar "Sketch->Import Library->QueueArray".

Once the library is imported, an "#include <QueueArray.h>" line will appear at the top of your Sketch.

Creation

Replace "T" with the data type you want to use.

QueueArray <T> queue;

Create instance (object) of a QueueArray class.

Methods

Replace "T" with the data type you want to use.

void enqueue (const T item)

Put an item with data type "T" to the queue.

T dequeue ()

Take an item with data type "T" from the front of the queue and remove it.

T front ()

Take an item with data type "T" from the front of the queue but do not remove it.

void push (const T item)

Same as enqueue.

T pop ()

Same as dequeue.

T peek ()

Same as front.

bool isEmpty ()

Check if the queue is empty.

bool isFull ()

Check if the queue is full.

int count ()

Get the number of items in the queue.

void setPrinter (Print & printer)

Sets the printer of the queue.

Examples

Manage a string by using a generic, dynamic queue data structure.

/*
* Manage a string by using a generic, dynamic queue data structure.
*
* Copyright (C) 2010 Efstathios Chatzikyriakidis (contact@efxa.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/