vbpupil/queue

A simple Queue data structure.

2.0.0 2022-09-06 18:52 UTC

This package is auto-updated.

Last update: 2024-05-06 23:17:38 UTC


README

PHP 8 Build Status Code Climate License: MIT

Queue Data Structure

A simple Queue data structure mechanism which allows you to set a max limit of items you wish to hold. After the max amount is met any subsequent additions will knock off items from the end.

Sample Usage

include 'vendor/autoload.php';

use vbpupil\Queue\Queue;

// create a new queue and specify a limit - here we have set it to hold 1 item.
$q = new Queue(1);

//add items
$q->addItem('Item 1')
    ->addItem('Item 2')
    ->addItem('Item 3')
    ->addItem('Item 4')
    ->addItem('Item 5');

echo($q->getItems());

The above example will return 1 item with the value of Item 5.