コード例 #1
0
 public bool goRight()
 {
     if (node != null)
     {
         if (node.rightNode != null)
         {
             // well it looks like I need a controller class after all
             node = node.rightNode;
             return(true);
         }
     }
     return(false);
 }
コード例 #2
0
 public void addRight(Object input)
 {
     if (node == null)
     {
         node = new linkNode(null, input, null);
     }
     else
     {
         node.rightNode = new linkNode(node, input, node.rightNode);
         // now to change the old right  node's left to this one if it exisits
         //goRight();
         if (node.rightNode.rightNode != null)
         {
             node.rightNode.rightNode.leftNode = node;
         }
     }
 }
コード例 #3
0
 // now for adding to the end or beginning
 // this will require checking that the list is not a looped list
 // and yeah I realise that if you have a tailed loop list this could
 // be a infinate loop
 // meh this is now a controller class and cant have a loopped list
 public bool addToEnd(Object input)
 {
     if (node == null)
     {
         node = new linkNode(null, input, null);
         return(true);
     }
     else
     {
         linkNode checker = node.rightNode;
         if (checker != null)
         {
             while (true)
             {
                 if (checker.rightNode != null)
                 {
                     // make sure its not a circular list
                     if (checker.rightNode != node)
                     {
                         checker = checker.rightNode;
                     }
                     else
                     {
                         return(false);
                     }
                 }
                 else
                 {
                     checker.rightNode = new linkNode(checker, input, null);
                     return(true);
                 }
             }
         }
         else
         {
             addRight(input);
             return(true);
         }
     }
 }
コード例 #4
0
 // add an item to the start of the linked list
 public bool addToStart(Object input)
 {
     if (node == null)
     {
         node = new linkNode(null, input, null);
         return(true);
     }
     else
     {
         linkNode checker = node.leftNode;
         if (checker != null)
         {
             while (true)
             {
                 if (checker.leftNode != null)
                 {
                     if (checker.leftNode != node)
                     {
                         checker = checker.leftNode;
                     }
                     else
                     {
                         return(false);
                     }
                 }
                 else
                 {
                     checker.leftNode = new linkNode(null, input, checker);
                     return(true);
                 }
             }
         }
         else
         {
             addLeft(input);
             return(true);
         }
     }
 }
コード例 #5
0
 // and now for a delete function
 public void deleteCurrent()
 {
     // first lets get the left and right nodes to link to each other cutting out the current node
     // only if the nodes exist to be added to of course
     if (isLeft())
     {
         node.leftNode.rightNode = node.rightNode;
     }
     if (isRight())
     {
         node.rightNode.leftNode = node.leftNode;
     }
     // now to switch to one of these node - lets check if one is null and
     // if so switch to the other, after all if both are null then its the
     // only one here and this will effectivly clear the list
     if (node.leftNode != null)
     {
         node = node.leftNode;
     }
     else
     {
         node = node.rightNode;
     }
 }
コード例 #6
0
 public linkNode(linkNode LeftNode, Object Data, linkNode RightNode)
 {
     leftNode  = LeftNode;
     data      = Data;
     rightNode = RightNode;
 }
コード例 #7
0
 // creating a new dbl linked list item as a stand alone(i.e the first one)
 public dblLinked(Object input)
 {
     node = new linkNode(null, input, null);
 }
コード例 #8
0
 // init class(s)
 public dblLinked()
 {
     node = null;
 }