SplDoublyLinkedList::offsetUnset

(PHP 5 >= 5.3.0)

SplDoublyLinkedList::offsetUnsetUnsets the value at the specified $index

Description

public void SplDoublyLinkedList::offsetUnset ( mixed $index )

Unsets the value at the specified index.

Parameters

index

The index being unset.

Return Values

No value is returned.

Errors/Exceptions

Throws OutOfRangeException when index is out of bounds or when index cannot be parsed as an integer.

Коментарии

When unsetting an offset, the element will be removed from the double linked list. So the following code:

<?php

$obj 
= new SplDoublyLinkedList();

$obj->push(4);
$obj->push(5);
$obj->push(6);

$obj->offsetUnset(1);
echo 
"Our Linked List:";
print_r($obj);

?>

Will output:

Our Linked List:SplDoublyLinkedList Object
(
    [flags:SplDoublyLinkedList:private] => 0
    [dllist:SplDoublyLinkedList:private] => Array
        (
            [0] => 4
            [1] => 5
            [2] => 6
        )

)
Our New Linked List:SplDoublyLinkedList Object
(
    [flags:SplDoublyLinkedList:private] => 0
    [dllist:SplDoublyLinkedList:private] => Array
        (
            [0] => 4
            [1] => 6
        )

Notice that the element with the index 2 has now the index 1. The original element with index 1 did not only had it's value unset but was also removed from the list.
2011-05-31 08:40:20
http://php5.kiev.ua/manual/ru/spldoublylinkedlist.offsetunset.html

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