SplDoublyLinkedList::bottom

(PHP 5 >= 5.3.0)

SplDoublyLinkedList::bottomPeeks at the node from the beginning of the doubly linked list

Description

public mixed SplDoublyLinkedList::bottom ( void )

Parameters

This function has no parameters.

Return Values

The value of the first node.

Errors/Exceptions

Throws RuntimeException when the data-structure is empty.

Коментарии

<?php

/*
 * Examples of DoublyLinkedList
 */

$obj = new SplDoublyLinkedList();

// Check wither linked list is empty
if ($obj->isEmpty())
{
    echo 
"Adding nodes to Linked List<br>";
   
$obj->push(2);
   
$obj->push(3);
   
    echo 
"Adding the node at beginning of doubly linked list <br>";
   
$obj->unshift(10);
}

echo 
"<br>Our Linked List:";
print_r($obj);

echo 
"<br>Pick the node from beginning of doubly linked list";
echo 
$obj->bottom();

?>
2011-01-27 00:39:01
http://php5.kiev.ua/manual/ru/spldoublylinkedlist.bottom.html
A note on top() and bottom():

Picture the doubly-linked list (or queue) in the same way that you would a stack.

Say you started with an empty queue, and added five values:

$myList = new SplDoublyLinkedList

$mylist->push(1)
$mylist->push(2)
$mylist->push(3)
$mylist->push(4)
$mylist->push(5)

$mylist->top()
-> 5

$mylist->bottom()
-> 1
2014-04-28 01:27:10
http://php5.kiev.ua/manual/ru/spldoublylinkedlist.bottom.html

    Поддержать сайт на родительском проекте КГБ