00001 <?php
00008 #include <zlist.php>
00009 include_once('/media/SRV/zigmoyd/usr/lib/module/common/zlinkedlist.php');
00010
00015 class zVect extends zList{
00022 function dataAt($atIndex){
00023 $i = 0;
00024 $dummyTmp = $this->getNext();
00025 while($dummyTmp->hasNext()){
00026 if($i == $atIndex)return $dummyTmp->getData();
00027 $dummyTmp = $dummyTmp->getNext();
00028 $i++;
00029 }
00030 if($i == $atIndex)return $dummyTmp->getData();
00031 return false;
00032 }
00039 function &at($atIndex){
00040 $i = 0;
00041 $dummyTmp = $this->getNext();
00042 while($dummyTmp->hasNext()){
00043 if($i == $atIndex)return $dummyTmp;
00044 $dummyTmp = $dummyTmp->getNext();
00045 $i++;
00046 }
00047 if($i == $atIndex)return $dummyTmp;
00048 perror("<code>zigmoyd.comon.vector.at()</code><br />Index $atIndex not accessible. Possible Causes: The length of the vector is less than the index you have Specified e.g. there is no node on $atIndex Index");
00049 return ($x=false);
00050 }
00057 function append($val){
00058 return parent::addData($val);
00059 }
00066 function insert($i, $val){
00067 $tmpCarry = $this->at($i);
00068 $tmpHold = $tmpCarry->getNext();
00069 $dummy = new zItem($this->type);
00070 $dummy->setData($val);
00071 $dummy->setNext($tmpHold);
00072 $tmpCarry->setNext($dummy);
00073 }
00080 function find($search){
00081 for($i=0;$i<$this->length();$i++){
00082 if($this->dataAt($i) == $search){
00083 return $i;
00084 }
00085 }
00086 return -1;
00087 }
00093 function detach($atIndex){
00094 $i = 0;
00095 $dummyTmp = &$this->link;
00096 while($dummyTmp->hasNext()){
00097 if($i == $atIndex)return $dummyTmp->removeNext();
00098 $dummyTmp = &$dummyTmp->link;
00099 $i++;
00100 }
00101 if($i == $atIndex)return $dummyTmp->removeNext();
00102 return false;
00103 }
00109 function remove($atIndex){
00110 $tmpCarry = $this->at($i);
00111 $tmpHold = $tmpCarry->getNext();
00112 $tmpCarry = $tmpCarry->getParent();
00113 $tmpCarry->setNext($tmpHold);
00114 }
00115 }
00116 class zVectIterator extends zCore{
00124 var $vector;
00132 var $direction=true;
00140 var $iterationIndex=-1;
00141
00142 function zVectIterator($vector){
00143 $this->vector = $vector;
00144 }
00149 function toFront(){
00150 $this->direction=true;
00151 $this->iterationIndex=0;
00152 }
00157 function toBack(){
00158 $this->direction=false;
00159 $this->iterationIndex=0;
00160 }
00166 function hasNext(){
00167 $currentNode = $this->vector->at($this->iterationIndex++);
00168 return $currentNode->hasNext();
00169 }
00175 function hasPrevious(){
00176 $currentNode = $this->vector->at($this->iterationIndex--);
00177 return $currentNode->hasParent();
00178 }
00184 function next(){
00185 $currentNode = $this->vector->at($this->iterationIndex);
00186 return $currentNode->getNext();
00187 }
00193 function previous(){
00194 $currentNode = $this->vector->at($this->iterationIndex);
00195 return $currentNode->getPrevious();
00196 }
00202 function value(){
00203 return $this->vector->dataAt($this->iterationIndex);
00204 }
00209 function remove(){
00210 $this->vector->remove($this->iterationIndex);
00211 }
00217 function setValue($val){
00218 $currentNode = $this->vector->at($this->iterationIndex);
00219 return $currentNode->setData($val);
00220 }
00226 function index(){
00227 return $this->iterationIndex;
00228 }
00234 function size(){
00235 return $this->vector->length();
00236 }
00242 function begin(){
00243 $currentNode = $this->vector->at($this->iterationIndex);
00244 return !$currentNode->hasParent();
00245 }
00250 function end(){
00251 $currentNode = $this->vector->at($this->iterationIndex);
00252 return !$currentNode->hasNext();
00253 }
00254 }
00256 ?>
00257 <?php
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275 ?>