@Test public void testSubList() { CategorizedCircularBuffer<String, Long> ccb = new CategorizedCircularBuffer<String, Long>(4); ccb.add(0l, "e0"); ccb.add(1l, "e2"); ccb.add(1l, "e3"); ccb.add(3l, "e4"); { List l = ccb.subList(2, 4); assertEquals(2, l.size()); assertEquals("e2", l.get(0)); assertEquals("e0", l.get(1)); List kl = ccb.subListByKey(1l, 0, 2); assertEquals(2, kl.size()); assertEquals("e3", kl.get(0)); assertEquals("e2", kl.get(1)); } ccb.add(3l, "e5"); { List l = ccb.subList(2, 4); assertEquals(2, l.size()); assertEquals("e3", l.get(0)); assertEquals("e2", l.get(1)); } ccb.add(3l, "e6"); { List kl = ccb.subListByKey(1l, 0, 1); assertEquals(1, kl.size()); assertEquals("e3", kl.get(0)); } }
public List<T> subList(int fromIndex, int toIndex) { List<T> ret = new ArrayList<T>(toIndex - fromIndex); for (Pair<T, K> pair : mainList.subList(fromIndex, toIndex)) { ret.add(pair.value); } return ret; }
CategorizedCircularBuffer { public List<T> subList(int fromIndex, int toIndex) { List<T> ret = new ArrayList<T>(toIndex - fromIndex); for (Pair<T, K> pair : mainList.subList(fromIndex, toIndex)) { ret.add(pair.value); } return ret; } }
CategorizedCircularBuffer { public List<T> subList(int fromIndex, int toIndex) { List<T> ret = new ArrayList<T>(toIndex - fromIndex); for (Pair<T, K> pair : mainList.subList(fromIndex, toIndex)) { ret.add(pair.value); } return ret; } CategorizedCircularBuffer(int maxCount); }
CategorizedCircularBuffer { public List<T> subList(int fromIndex, int toIndex) { List<T> ret = new ArrayList<T>(toIndex - fromIndex); for (Pair<T, K> pair : mainList.subList(fromIndex, toIndex)) { ret.add(pair.value); } return ret; } CategorizedCircularBuffer(int maxCount); void add(K key, T value); List<T> subList(int fromIndex, int toIndex); int size(); List<T> subListByKey(K key, int fromIndex, int toIndex); int sizeByKey(K key); }
CategorizedCircularBuffer { public List<T> subList(int fromIndex, int toIndex) { List<T> ret = new ArrayList<T>(toIndex - fromIndex); for (Pair<T, K> pair : mainList.subList(fromIndex, toIndex)) { ret.add(pair.value); } return ret; } CategorizedCircularBuffer(int maxCount); void add(K key, T value); List<T> subList(int fromIndex, int toIndex); int size(); List<T> subListByKey(K key, int fromIndex, int toIndex); int sizeByKey(K key);  }