Mark Herschberg, author of The Career Toolkit
https://www.thecareertoolkitbook.com/
Originally posted by Mark Herschberg:
The catch is when creating it, I'm always running into null pointer exceptions. I either need to handle a couple base cases on both ends (0-1-2 elements in list to start, or adding to last or second to last element), or I need to keep direct references to two elements at once, either current and previous, or current and next.
"I'm not back." - Bill Harding, Twister
Originally posted by David O'Meara:
I'm coming in late, but do you really need a doubly linked list?
I'm thinking that using a plain old List (like an ArrayList) plus a Comparator to sort, then you can use Collections.sort(List, Comparator) for sorting, and get the reverse list using Collections.reverse(List)
Originally posted by Jim Yingst:
Just off the top of my head, I'd probably look at the implementation of java.util.LinkedList. Assuming it's not already adequate for your needs, you can probably speed it up by modifying it to take an int value directly rather than an Object.
...
Also, it seems that the standard "Intermediate Java" answer would be "just use a LinkedList" - since you evidently want something more performant, perhaps this topic would do better in Performance?
"I'm not back." - Bill Harding, Twister
Consider Paul's rocket mass heater. |