@Test public void readBackward() { int size = 16; FixedSizeCircularLinkedList<AtomicInteger> list = new FixedSizeCircularLinkedList<AtomicInteger>(size, AtomicInteger.class); for (int i = 0; i < size; i++) { list.head().set(i); list.rotateForward(); } assertEquals(15, list.readBackward(1).get(0).get()); List<AtomicInteger> five = list.readBackward(5); int sumOfFive = 0; for (int i = 0; i < 5; i++) { sumOfFive += five.get(i).get(); } assertEquals(65, sumOfFive); List<AtomicInteger> fifteen = list.readBackward(15); int sumOfFifteen = 0; for (int i = 0; i < 15; i++) { sumOfFifteen += fifteen.get(i).get(); } assertEquals(120, sumOfFifteen); }
public List<T> readBackward(int count) { List<T> data = new ArrayList<T>(count); Node<T> node = head.getPrevious(); for (int i = 0; i < count; i++) { data.add(node.getData()); node = node.getPrevious(); } return data; }
FixedSizeCircularLinkedList { public List<T> readBackward(int count) { List<T> data = new ArrayList<T>(count); Node<T> node = head.getPrevious(); for (int i = 0; i < count; i++) { data.add(node.getData()); node = node.getPrevious(); } return data; } }
FixedSizeCircularLinkedList { public List<T> readBackward(int count) { List<T> data = new ArrayList<T>(count); Node<T> node = head.getPrevious(); for (int i = 0; i < count; i++) { data.add(node.getData()); node = node.getPrevious(); } return data; } FixedSizeCircularLinkedList(int size, Class<T> type); }
FixedSizeCircularLinkedList { public List<T> readBackward(int count) { List<T> data = new ArrayList<T>(count); Node<T> node = head.getPrevious(); for (int i = 0; i < count; i++) { data.add(node.getData()); node = node.getPrevious(); } return data; } FixedSizeCircularLinkedList(int size, Class<T> type); T head(); void rotateForward(); List<T> readBackward(int count); String toString(); }
FixedSizeCircularLinkedList { public List<T> readBackward(int count) { List<T> data = new ArrayList<T>(count); Node<T> node = head.getPrevious(); for (int i = 0; i < count; i++) { data.add(node.getData()); node = node.getPrevious(); } return data; } FixedSizeCircularLinkedList(int size, Class<T> type); T head(); void rotateForward(); List<T> readBackward(int count); String toString();  }