SplDoublyLinkedList::offsetSet

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

SplDoublyLinkedList::offsetSetSpécifie la nouvelle valeur de l'index

Description

public SplDoublyLinkedList::offsetSet(?int $index, mixed $value): void

Définit la valeur de l'index à la valeur value.

Liste de paramètres

index

L'index à définir. Si null la prochaine valeur sera ajouté après la dernière valeur.

value

La nouvelle valeur pour l'index.

Valeurs de retour

Aucune valeur n'est retournée.

Erreurs / Exceptions

Lance une exception OutOfRangeException lorsque index est en dehors des limites ou lorsque index ne peut être analysé comme un entier.

add a note

User Contributed Notes 1 note

up
0
chanel at lipski-development dot de
7 years ago
How to change elements of a SplDoublyLinkedList<?php function change_elements($list,$old_index,$new_index){    $tmp1=$list->offsetGet($old_index);$tmp2=$list->offsetGet($new_index);$list->offsetSet($old_index,$tmp2);$list->offsetSet($new_index,$tmp1);}$list=new SplDoublyLinkedList(); $list->push("A");$list->push("B");$list->push("C");/*OUTPUTABC*/change_elements($list,0,1);/*OUTPUTBAC*/?>
To Top