Results 1 to 4 of 4
Thread: sorting linkedList??
- 03-24-2011, 04:44 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 5
- Rep Power
- 0
sorting linkedList??
hi.. i have a LinkedList class and another Transaction class which are defined by myself.. my objective is to insert the transaction into the linkedList in chronological order... in my link list i have this method:
the transaction class is defined in this way:Java Code:public void insertAcd (E newItem) { Node <E> pre,cur; E curItem; if (numItems==0) { head = new Node<E>(newItem); numItems++; return; } numItems++; curItem=head.item; if (curItem.compareTo(newItem)>=0) { head = new Node<E>(newItem, head); return; } pre = head; cur = pre.next; for(;cur!=null;) { curItem=cur.item; if (curItem.compareTo(newItem)>=0) break; pre = cur; cur = cur.next; } pre.next=new Node<E>(newItem,cur); }
Java Code:Transaction trans = new Transaction (accountNumber,date,time,type,amount,place)
- 03-24-2011, 04:47 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 03-25-2011, 01:25 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 5
- Rep Power
- 0
my question was how do i sort the linked list according to datetime...
but i have solve it already... thx anyway
- 03-28-2011, 11:48 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
So could you please mark the thread solved then. :)
Similar Threads
-
LinkedList and archives
By veronica in forum New To JavaReplies: 3Last Post: 02-04-2011, 03:54 PM -
LinkedList
By [RaIdEn] in forum New To JavaReplies: 7Last Post: 10-13-2009, 12:59 AM -
LinkedList help
By jigglywiggly in forum New To JavaReplies: 6Last Post: 09-19-2009, 07:24 AM -
LinkedList problem
By Mika in forum New To JavaReplies: 7Last Post: 02-18-2009, 02:10 PM -
how to use LinkedList
By fred in forum Advanced JavaReplies: 1Last Post: 07-24-2007, 01:52 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks