SplDoublyLinkedList::offsetSet

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

SplDoublyLinkedList::offsetSetEstablece el valor del índice específicado

Descripción

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

Establece el valor del índice dado por index al valor especificado por value.

Parámetros

index

El índice a establer. Si null, el siguiente valor se añadirá después del último elemento.

value

El nuevo valor para index.

Valores devueltos

No devuelve ningún valor.

Errores/Excepciones

Lanza una OutOfRangeException cuando index está fuera de los límites o cuando index no se puede analizar como un entero.

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