Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddItem(S)
- {
- if (firstItem == null)
- firstItem = lastItem = new Item(S);
- else
- {
- Item sortingItem = firstItem;
- Item newItem = new Item(S);
- // Logic for when only 1 item is in the array
- // because while will not run in this case
- while(sortingItem.hasNext())
- {
- if (sortingItem.compareTo(newItem) < 0)
- {
- newItem.setPrevious(sortingItem.previous);
- sortingItem.setPrevious(newItem);
- newItem.setNext(sortinItem);
- if(newItem.previous = null)
- firstItem = newItem;
- else
- newItem.previous.setNext(newItem);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement