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];
 
An exception for terminatinating execution or to throw for unit testing.
A zipper is a purely-functional data structure which contains a focus that can be efficiently manipul...
insertBefore($t)
Insert element before hole.
splice($t, $delete, $replacement)
Splice in multiple elements at hole.
__construct($front, $back)
advance($t, $n)
Iterated hole advancement.
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.
toArray($t=NULL)
Convert zipper back into a normal array, optionally filling in the hole with a value.
done()
Returns true if we are at the end of the list.
prev($t)
Move hole to the previous element.
insertAfter($t)
Insert element after hole.