Here is simple examples of SplQueue: -
<?php
echo "Create Object of Spl. Queue:";
$obj = new SplQueue();
echo "<br>Check for Queue is Empty:";
if($obj->isEmpty())
{
$obj->enqueue("Simple");
$obj->enqueue("Example");
$obj->enqueue("Of");
$obj->enqueue("PHP");
}
echo "<br>View queue:";
print_r($obj);
if(! $obj->offsetExists(4))
{
$obj->enqueue(10);
}
print_r($obj);
echo "<br>Get the value of the offset at 3 ";
if($obj->offsetGet(3))
{
echo $obj->offsetGet(3);
echo "<br>Resetting the value of a node:";
$obj->offsetSet(4,6);
}
?>
The SplDoublyLinkedList class
(PHP 5 >= 5.3.0)
Introduction
The SplDoublyLinkedList class provides the main functionalities of a doubly linked list.
Class synopsis
/* Methods */
}Table of Contents
- SplDoublyLinkedList::bottom — Peeks at the node from the beginning of the doubly linked list
- SplDoublyLinkedList::__construct — Constructs a new doubly linked list
- SplDoublyLinkedList::count — Counts the number of elements in the doubly linked list.
- SplDoublyLinkedList::current — Return current array entry
- SplDoublyLinkedList::getIteratorMode — Returns the mode of iteration
- SplDoublyLinkedList::isEmpty — Checks whether the doubly linked list is empty.
- SplDoublyLinkedList::key — Return current node index
- SplDoublyLinkedList::next — Move to next entry
- SplDoublyLinkedList::offsetExists — Returns whether the requested $index exists
- SplDoublyLinkedList::offsetGet — Returns the value at the specified $index
- SplDoublyLinkedList::offsetSet — Sets the value at the specified $index to $newval
- SplDoublyLinkedList::offsetUnset — Unsets the value at the specified $index
- SplDoublyLinkedList::pop — Pops a node from the end of the doubly linked list
- SplDoublyLinkedList::prev — Move to previous entry
- SplDoublyLinkedList::push — Pushes an element at the end of the doubly linked list
- SplDoublyLinkedList::rewind — Rewind iterator back to the start
- SplDoublyLinkedList::serialize — Serializes the storage
- SplDoublyLinkedList::setIteratorMode — Sets the mode of iteration
- SplDoublyLinkedList::shift — Shifts a node from the beginning of the doubly linked list
- SplDoublyLinkedList::top — Peeks at the node from the end of the doubly linked list
- SplDoublyLinkedList::unserialize — Unserializes the storage
- SplDoublyLinkedList::unshift — Prepends the doubly linked list with an element
- SplDoublyLinkedList::valid — Check whether the doubly linked list contains more nodes
rakesh dot mishra at gmail dot com ¶
2 years ago
