@Test public void findIndexTest() { SampleData data = new SampleData(); data.weights = new int[]{3, 8, 27, 6, 8, 2, 9, 21}; data.strings = new String[]{"Bleh", "Foo", "Snide", "Mesh", "Gree", "Fnex", "Moose", "Twa"}; WeightedList<String> list = demoList(data); int sum = 0; for (int i = 0; i < data.strings.length; i++) { assertThat(list.findIndex(data.strings[i]), is(sum)); sum += data.weights[i]; } }
int findIndex(E element) { for (Integer thisKey = 0; thisKey != null; thisKey = map.higherKey(thisKey)) if (map.get(thisKey).equals(element)) return thisKey; return -1; }
WeightedList implements Cloneable { int findIndex(E element) { for (Integer thisKey = 0; thisKey != null; thisKey = map.higherKey(thisKey)) if (map.get(thisKey).equals(element)) return thisKey; return -1; } }
WeightedList implements Cloneable { int findIndex(E element) { for (Integer thisKey = 0; thisKey != null; thisKey = map.higherKey(thisKey)) if (map.get(thisKey).equals(element)) return thisKey; return -1; }  }
WeightedList implements Cloneable { int findIndex(E element) { for (Integer thisKey = 0; thisKey != null; thisKey = map.higherKey(thisKey)) if (map.get(thisKey).equals(element)) return thisKey; return -1; }  int count(); @SuppressWarnings("unchecked") @Override WeightedList<E> clone(); }
WeightedList implements Cloneable { int findIndex(E element) { for (Integer thisKey = 0; thisKey != null; thisKey = map.higherKey(thisKey)) if (map.get(thisKey).equals(element)) return thisKey; return -1; }  int count(); @SuppressWarnings("unchecked") @Override WeightedList<E> clone();  }