/** * Finds the index at which object should be inserted. */ public int findInsertionPoint(E o) { return findInsertionPoint(o, 0, size() - 1); }
/** * Finds the index at which object should be inserted. */ public int findInsertionPoint(final E o) { return findInsertionPoint(o, 0, size() - 1); }
@Test void testList2() { SortedArrayList<String> list = new SortedArrayList<>(); list.add("bbb"); list.add("aaa"); assertEquals(2, list.size()); assertEquals("aaa", list.get(0)); assertEquals("bbb", list.get(1)); list.add("aa"); assertEquals(3, list.size()); assertEquals("aa", list.get(0)); list.add("a"); assertEquals(4, list.size()); assertEquals("a", list.get(0)); assertEquals(1, list.findInsertionPoint("a")); }
@Test void testComparator(){ Comparator<String> comparator = new Comparator<String>() { @Override public int compare(String str1, String str2) { if (str1 == null && str2 == null) { return 0; } if (str1 == null) { return 1; } if (str2 == null) { return -1; } return str2.compareTo(str1); } }; SortedArrayList<String> list = new SortedArrayList<>(comparator); assertNotNull(list.getComparator()); list.add("aaa"); list.add("bbb"); assertEquals(2, list.size()); assertEquals("bbb", list.get(0)); assertEquals("aaa", list.get(1)); } }
@Override protected int getLastIndex() { return list.size() - 1; } }
/** * Finds the index at which object should be inserted. */ public int findInsertionPoint(E o) { return findInsertionPoint(o, 0, size() - 1); }
/** * Finds the index at which object should be inserted. */ public int findInsertionPoint(final E o) { return findInsertionPoint(o, 0, size() - 1); }
int high = list.size() - 1; int macroNdx = 0; for (int deep = 0; deep < actionChunks.length; deep++) {