37 $z =
new self(
array(), array_reverse($array));
49 if (
$t !== NULL) $a[] =
$t;
50 for (
$i = count($this->
back)-1;
$i >= 0;
$i--) {
62 if (
$t !== NULL) array_push($this->front,
$t);
63 return empty($this->
back) ? NULL : array_pop($this->
back);
85 if (
$t !== NULL) array_push($this->
back,
$t);
86 return empty($this->front) ? NULL : array_pop($this->front);
94 public function delete() {
95 return empty($this->
back) ? NULL : array_pop($this->
back);
103 return empty($this->
back);
111 if (
$t !== NULL) array_push($this->front,
$t);
119 if (
$t !== NULL) array_push($this->
back,
$t);
142 public function splice(
$t, $delete, $replacement) {
146 for (
$i = $delete;
$i > 0;
$i--) {
148 $r = $this->
delete();
151 for (
$i = count($replacement)-1;
$i >= 0;
$i--) {
153 $r = $replacement[
$i];
done()
Returns true if we are at the end of the list.
splice($t, $delete, $replacement)
Splice in multiple elements at hole.
advance($t, $n)
Iterated hole advancement.
insertAfter($t)
Insert element after hole.
insertBefore($t)
Insert element before hole.
toArray($t=NULL)
Convert zipper back into a normal array, optionally filling in the hole with a value.
__construct($front, $back)
A zipper is a purely-functional data structure which contains a focus that can be efficiently manipul...
Create styles array
The data for the language used.
prev($t)
Move hole to the previous element.
next($t)
Move hole to the next element.
static fromArray($array)
Creates a zipper from an array, with a hole in the 0-index position.