Boubly linked list. Remove function and insert


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Boubly linked list. Remove function and insert

  1. #1
    Join Date
    Oct 2005
    Posts
    1

    Boubly linked list. Remove function and insert

    Could me someone help in this functions.
    Code:
    public void Insert(Element el, int placeNr){ 
           if (placeNr<= this.ElementCount()){ 
               int i; 
               Element el1 = this.first; 
               Element newElement = new Element(); 
               if ((el1 == null)||(EilNr == 0)) { 
                       newElement = el.Copy(); 
                       newElement.next=this.first; 
                       this.first = newElement; 
               }else for (i=1;(el1!=null)||(i<placeNr); i++){ 
                       if (i==placeNr){ 
      newElement=el.Copy(); 
                       newElement.next=el1.next; 
                       el1.next=newElement; 
                       } 
                       el1 = el1.next; 
                   } 
               } 
        } 
      public void Remove(int placeNr){ 
           if ((placeNr>0)&&(placeNr<= this.ElementCount())){ 
               int i; 
               if (this.first.next!=null) 
    {              Element el1 = this.first;  
                   if (placeNr==1){this.first=el1.next;} else { 
                       for (i=2; i<placeNr; i++){ 
                          el1 = el1.next; 
                       } 
                       el1.next = el1.next.next; 
                  } 
               } else {this.first = null;} 
           } 
        }
    I whant to rewrite theese functions to fit for Doubly Linked List. But i do not know how it to do. I know only that doubly linked list have 2 pointers first and tail or end pointer. Maybe someone have an example or tutorials for theese functions ???? I need very very help for this
    Last edited by woo; 10-11-2005 at 08:50 AM. Reason: added

  2. #2
    Join Date
    Oct 2005
    Posts
    40

    Arrow

    Read the "Advanced Linked Lists" column here

    http://www.theparticle.com/javadata2.html#Linked_Lists

    Regards,
    Mohit

Similar Threads

  1. Packed Data(Comp-3, etc)
    By Marcos in forum VB Classic
    Replies: 3
    Last Post: 01-25-2006, 11:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center