PHP Класс HTMLPurifier_Zipper, yii

Base list: 1 2 3 4 [ ] 6 7 8 9 Front list: 1 2 3 4 Back list: 9 8 7 6 User is expected to keep track of the "current element" and properly fill it back in as necessary. (ToDo: Maybe it's more user friendly to implicitly track the current element?) Nota bene: the current class gets confused if you try to store NULLs in the list.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$back
$front

Открытые методы

Метод Описание
__construct ( $front, $back )
advance ( $t, $n ) : Original Iterated hole advancement.
delete ( ) : Original Delete contents of current hole, shifting hole to next element.
done ( ) : boolean Returns true if we are at the end of the list.
fromArray ( $array ) : Tuple Creates a zipper from an array, with a hole in the 0-index position.
insertAfter ( $t ) Insert element after hole.
insertBefore ( $t ) Insert element before hole.
next ( $t ) : Original Move hole to the next element.
prev ( $t ) : Original Move hole to the previous element
splice ( $t, $delete, $replacement ) Splice in multiple elements at hole. Functional specification in terms of array_splice:
toArray ( $t = NULL ) Convert zipper back into a normal array, optionally filling in the hole with a value. (Usually you should supply a $t, unless you are at the end of the array.)

Описание методов

__construct() публичный Метод

public __construct ( $front, $back )

advance() публичный Метод

Iterated hole advancement.
public advance ( $t, $n ) : Original
$t Element to fill hole with
Результат Original contents of new hole, i away

delete() публичный Метод

Delete contents of current hole, shifting hole to next element.
public delete ( ) : Original
Результат Original contents of new hole.

done() публичный Метод

Returns true if we are at the end of the list.
public done ( ) : boolean
Результат boolean

fromArray() публичный статический Метод

Creates a zipper from an array, with a hole in the 0-index position.
public static fromArray ( $array ) : Tuple
Результат Tuple of zipper and element of first position.

insertAfter() публичный Метод

Insert element after hole.
public insertAfter ( $t )

insertBefore() публичный Метод

Insert element before hole.
public insertBefore ( $t )

next() публичный Метод

Move hole to the next element.
public next ( $t ) : Original
$t Element to fill hole with
Результат Original contents of new hole.

prev() публичный Метод

Move hole to the previous element
public prev ( $t ) : Original
$t Element to fill hole with
Результат Original contents of new hole.

splice() публичный Метод

$arr1 = $arr; $old1 = array_splice($arr1, $i, $delete, $replacement); list($z, $t) = HTMLPurifier_Zipper::fromArray($arr); $t = $z->advance($t, $i); list($old2, $t) = $z->splice($t, $delete, $replacement); $arr2 = $z->toArray($t); assert($old1 === $old2); assert($arr1 === $arr2); NB: the absolute index location after this operation is *unchanged!*
public splice ( $t, $delete, $replacement )

toArray() публичный Метод

Convert zipper back into a normal array, optionally filling in the hole with a value. (Usually you should supply a $t, unless you are at the end of the array.)
public toArray ( $t = NULL )

Описание свойств

$back публичное свойство

public $back

$front публичное свойство

public $front