Oo Php

Thread Solved

Join Date: Apr 2007
Posts: 439
Reputation: Fungus1487 is on a distinguished road 
Solved Threads: 50
Fungus1487's Avatar
Fungus1487 Fungus1487 is offline Offline
Posting Pro in Training

Oo Php

 
0
  #1
Jun 7th, 2007
well ive been doing some work with object oriented php and came across a question i couldnt answer. can you create a list i.e. similiar to a linkedlist in java or the like in php ?
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 42
Reputation: UrbanSky is an unknown quantity at this point 
Solved Threads: 4
UrbanSky UrbanSky is offline Offline
Light Poster

Re: Oo Php

 
0
  #2
Jun 8th, 2007
Yes not a problem, this the code for a list node. Writting the rest of the operation functions are quite easy once you have a node.

 <?php 
class ListNode{ 
    var $previousNode; 
    var $nextNode; //a reference to the next node 
    var $element; //the object || value for this node. 
     
    /** 
     * Constructs a ListNode. 
     * @param $element The object/value of the node 
     */ 
    function ListNode($element = NULL){ 
        $this->element = &$element; 
    } 
     
    /** 
     * Sets the reference to the previous node. 
     * @param &$node The previous node. 
     */ 
    function setPrevious($node){ 
        $this->previousNode = &$node; 
    } 
     
    /** 
     * Sets the reference to the next node. 
     * @param &$node The next node. 
     */ 
    function setNext($node){ 
        $this->nextNode = &$node; 
    } 
     
    /** 
     * Returns the reference to the previous node. 
     * @return The reference to the previous node. 
     */ 
    function &getPrevious(){ 
        return $this->previousNode; 
    } 

    /** 
     * Returns the reference to the next node. 
     * @return The reference to the next node. 
     */ 
    function &getNext(){ 
        return $this->nextNode; 
    } 

    /** 
     * Returns the object/value of the node 
     * @return The object/value of the node 
     */ 
    function getNodeValue(){ 
        return $this->element; 
    } 
} 
?> 

Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 439
Reputation: Fungus1487 is on a distinguished road 
Solved Threads: 50
Fungus1487's Avatar
Fungus1487 Fungus1487 is offline Offline
Posting Pro in Training

Re: Oo Php

 
0
  #3
Jun 8th, 2007
brilliant thanks
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 859 | Replies: 2
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC