PHP Class 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.
Mostra file Open project: yiisoft/yii Class Usage Examples

Public Properties

Property Type Description
$back
$front

Public Methods

Method Description
__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.)

Method Details

__construct() public method

public __construct ( $front, $back )

advance() public method

Iterated hole advancement.
public advance ( $t, $n ) : Original
$t Element to fill hole with
return Original contents of new hole, i away

delete() public method

Delete contents of current hole, shifting hole to next element.
public delete ( ) : Original
return Original contents of new hole.

done() public method

Returns true if we are at the end of the list.
public done ( ) : boolean
return boolean

fromArray() public static method

Creates a zipper from an array, with a hole in the 0-index position.
public static fromArray ( $array ) : Tuple
return Tuple of zipper and element of first position.

insertAfter() public method

Insert element after hole.
public insertAfter ( $t )

insertBefore() public method

Insert element before hole.
public insertBefore ( $t )

next() public method

Move hole to the next element.
public next ( $t ) : Original
$t Element to fill hole with
return Original contents of new hole.

prev() public method

Move hole to the previous element
public prev ( $t ) : Original
$t Element to fill hole with
return Original contents of new hole.

splice() public method

$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() public method

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 )

Property Details

$back public_oe property

public $back

$front public_oe property

public $front