Loading Please wait...

zVect Class Reference
[OOPS data structures.]

Implementation of Vector by Using Linked List. More...

Inheritance diagram for zVect:

Inheritance graph
[legend]
Collaboration diagram for zVect:

Collaboration graph
[legend]

Public Member Functions

 dataAt ($atIndex)
 Return's teh Data at i'th Node.
at ($atIndex)
 Return the i'th Node Itself.
 append ($val)
 Appends a Data to teh Vector.
 insert ($i, $val)
 Inserts data on the specified Index.
 find ($search)
 Serches with the Data in the Vector and returns the matching Node's Index return's -1 if not found.
 detach ($atIndex)
 Removes a Node and Its Child Nodes too.
 remove ($atIndex)
 Remove the specified Node only.

Detailed Description

Implementation of Vector by Using Linked List.

Definition at line 15 of file zvect.php.


Member Function Documentation

zVect::dataAt ( atIndex  ) 

Return's teh Data at i'th Node.

Parameters:
$atIndex integer
Returns:
mixed

Definition at line 22 of file zvect.php.

References zItem::getNext(), and zItem::hasNext().

Referenced by find().

00022                            {
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   }

Here is the call graph for this function:

& zVect::at ( atIndex  ) 

Return the i'th Node Itself.

Parameters:
$atIndex integer
Returns:
zItem

Definition at line 39 of file zvect.php.

References zItem::getNext(), zItem::hasNext(), and perror().

Referenced by insert(), and remove().

00039                         {
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   }

Here is the call graph for this function:

zVect::append ( val  ) 

Appends a Data to teh Vector.

Parameters:
$val mixed
Returns:
boolean

Definition at line 57 of file zvect.php.

References $val.

00057                        {
00058     return parent::addData($val);
00059   }

zVect::insert ( i,
val 
)

Inserts data on the specified Index.

Parameters:
$i integer
$val zItem

Definition at line 66 of file zvect.php.

References $val, at(), and zItem::zItem().

00066                            {
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   }

Here is the call graph for this function:

zVect::find ( search  ) 

Serches with the Data in the Vector and returns the matching Node's Index return's -1 if not found.

Parameters:
$search mixed
Returns:
Integer

Definition at line 80 of file zvect.php.

References dataAt(), and zList::length().

00080                         {
00081     for($i=0;$i<$this->length();$i++){
00082       if($this->dataAt($i) == $search){
00083         return $i;
00084       }
00085     }
00086     return -1;
00087   }

Here is the call graph for this function:

zVect::detach ( atIndex  ) 

Removes a Node and Its Child Nodes too.

Parameters:
$atIndex integer

Definition at line 93 of file zvect.php.

References zItem::hasNext().

00093                            {
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   }

Here is the call graph for this function:

zVect::remove ( atIndex  ) 

Remove the specified Node only.

Parameters:
$atIndex integer

Definition at line 109 of file zvect.php.

References at().

00109                            {
00110     $tmpCarry = $this->at($i);
00111     $tmpHold = $tmpCarry->getNext();
00112     $tmpCarry = $tmpCarry->getParent();
00113     $tmpCarry->setNext($tmpHold);
00114   }

Here is the call graph for this function:


The documentation for this class was generated from the following file:

Generated on Mon Oct 27 23:54:36 2008 for zigmoyd.kdevelop by doxygen 1.5.6