Anyone actually using this is almost certainly committing a heinous premature optimization.
interface LinkedList
class BasicLinkedList implements LinkedList
class XORLinkedList implements LinkedList
#ifdef _DEBUG
typedef BasicLinkedList LinkedList
#else
typedef XorLinkedList LinkedList
#endif [0] http://en.wikipedia.org/wiki/Policy-based_design
[1] http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern#Static_polymorphism LinkedList<Element> list = new XORLinkedList(Collections.fromArray(arrayList));
Element ele = list.get(4); //Ok, when we construct the list we can store the first and second pointers and traverse to the fourth
Element next = ele.next(); //???You need an Iterator type that has the address of the previous and current nodes, in addition to your existing node / Element type.
LinkedList<Element> list = new XORLinkedList(Collections.fromArray(arrayList));
Iterator<Element> it = list.get(4); //now you can access it.element for data from index 4
it.next(); // now access it.element for data from index 5