@Test public void testIndexOf() { BasicEventList<Object> source = new BasicEventList<>(); UniqueList<Object> unique = new UniqueList<>(source); Integer one = new Integer(1); for(int i = 0; i < 12; i++) { source.add(one); } Integer five = new Integer(5); for(int i = 0; i < 13; i++) { source.add(five); } Integer nine = new Integer(9); for(int i = 0; i < 10; i++) { source.add(nine); } int firstTestIndex = unique.indexOf(one); assertEquals(0, firstTestIndex); int secondTestIndex = unique.indexOf(five); assertEquals(1, secondTestIndex); int thirdTestIndex = unique.indexOf(nine); assertEquals(2, thirdTestIndex); Integer ten = new Integer(10); int fourthTest = unique.indexOf(ten); assertEquals(-1, fourthTest); }
@Override public int indexOf(Object element) { final int index = Collections.binarySearch(this, (E) element, ((SortedList<E>)source).getComparator()); return index < 0 ? -1 : index; }
UniqueList extends TransformedList<E, E> { @Override public int indexOf(Object element) { final int index = Collections.binarySearch(this, (E) element, ((SortedList<E>)source).getComparator()); return index < 0 ? -1 : index; } }
UniqueList extends TransformedList<E, E> { @Override public int indexOf(Object element) { final int index = Collections.binarySearch(this, (E) element, ((SortedList<E>)source).getComparator()); return index < 0 ? -1 : index; } UniqueList(EventList<E> source);  UniqueList(EventList<E> source, Comparator<? super E> comparator); private  UniqueList(SortedList<E> source, Void dummyParameter); }
UniqueList extends TransformedList<E, E> { @Override public int indexOf(Object element) { final int index = Collections.binarySearch(this, (E) element, ((SortedList<E>)source).getComparator()); return index < 0 ? -1 : index; } UniqueList(EventList<E> source);  UniqueList(EventList<E> source, Comparator<? super E> comparator); private  UniqueList(SortedList<E> source, Void dummyParameter); static UniqueList<E> create(EventList<E> source); void setComparator(Comparator<? super E> comparator); @Override int size(); @Override E remove(int index); @Override E set(int index, E value); @Override int indexOf(Object element); @Override void listChanged(ListEvent<E> listChanges); int getCount(int index); int getCount(E value); List<E> getAll(int index); List<E> getAll(E value); @Override void dispose(); }
UniqueList extends TransformedList<E, E> { @Override public int indexOf(Object element) { final int index = Collections.binarySearch(this, (E) element, ((SortedList<E>)source).getComparator()); return index < 0 ? -1 : index; } UniqueList(EventList<E> source);  UniqueList(EventList<E> source, Comparator<? super E> comparator); private  UniqueList(SortedList<E> source, Void dummyParameter); static UniqueList<E> create(EventList<E> source); void setComparator(Comparator<? super E> comparator); @Override int size(); @Override E remove(int index); @Override E set(int index, E value); @Override int indexOf(Object element); @Override void listChanged(ListEvent<E> listChanges); int getCount(int index); int getCount(E value); List<E> getAll(int index); List<E> getAll(E value); @Override void dispose();  }