All pastes #749629 Raw Edit

_Lemon_

public text v1 · immutable
#749629 ·published 2007-10-25 20:31 UTC
rendered paste body
<?php


 //Mostly for error objects :(
  //LIES!
 class vector
 {
  protected $vector = array();
  protected $count = 0;

  public function add($entry) { $this->vector[$this->count++] = $entry; }

  public function size() { return $this->count; }
  public function &at($position) { if(isset($this->vector[$position])) $return = &$this->vector[$position]; else $return = false; return $return; }

  public function raw() { return($this->vector); }
  public function write(html &$html, $element = 'li', $encap = 'ul')
  {
   if(isset($encap[0]))
    $html->raw('<'.$encap.'>', 1);
   for($a = 0; $a < $this->count; ++$a)
    $html->raw('<'.$element.'>'.$this->vector[$a].'</'.$element.'>', 0);
   if(isset($encap[0]))
    $html->raw('</'.$encap.'>', -1);
  }

  //Eeek! Remove me :(
  public function display() { print_r($this->vector); }
 };