Results 1 to 2 of 2

Thread: SLinkedList

  1. #1
    Mika is offline Member
    Join Date
    Dec 2008
    Location
    Davao Oriental
    Posts
    29
    Rep Power
    0

  2. #2
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    10

    Default

    I've ripped this from the text book. (Hope its ok?)
    Hadn't gone this far myself yet.

    PHP Code:
    class Node {
      Object element;
      Node next;
      
      public Node(Object o){
        element = o;
      }
    }
    
    [B]USAGE:[/B]
    Node first, last;
    
    // create a node to store the first circle object
    first = new Node(new Circle(1));
    last = first;
    
    // create a node to store the second circle object
    last.next = new Node(new Circle(2));
    last = last.next;
    
    // third circle object
    last.next = new Node(new Circle(3));
    last = last.next;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •