Add linked-list module: singly and doubly lists with measured costs, reverse, middle, Floyd cycle detection, merge and 5 more interview problems, the 2015 menu programs and a doubly-list bug they exposed (15 tests, 15 transcripts)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6r9iSyHu5qSJMzH2n
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
java.util.LinkedList, read from this JDK
|
||||
========================================
|
||||
|
||||
JDK: 25.0.5.1+2-LTS
|
||||
|
||||
fields of java.util.LinkedList$Node (reflection): [Node next, Node prev, Object item]
|
||||
interfaces of java.util.LinkedList: [List, Deque, Cloneable, Serializable]
|
||||
|
||||
java/util/LinkedList.java, node(int index), from line 578:
|
||||
578 Node<E> node(int index) {
|
||||
579 // assert isElementIndex(index);
|
||||
580
|
||||
581 if (index < (size >> 1)) {
|
||||
582 Node<E> x = first;
|
||||
583 for (int i = 0; i < index; i++)
|
||||
584 x = x.next;
|
||||
585 return x;
|
||||
586 } else {
|
||||
587 Node<E> x = last;
|
||||
588 for (int i = size - 1; i > index; i--)
|
||||
589 x = x.prev;
|
||||
590 return x;
|
||||
591 }
|
||||
592 }
|
||||
Reference in New Issue
Block a user