/** * Returns the number of duplicates of the value found at the specified index. */ public int getCount(int index) { int startIndex = getSourceIndex(index); int endIndex = getEndIndex(index); return endIndex - startIndex; }
/** * Returns the number of duplicates of the value found at the specified index. */ public int getCount(int index) { int startIndex = getSourceIndex(index); int endIndex = getEndIndex(index); return endIndex - startIndex; }
/** * Returns the number of duplicates of the value found at the specified index. */ public int getCount(int index) { int startIndex = getSourceIndex(index); int endIndex = getEndIndex(index); return endIndex - startIndex; }
/** * Returns a List of all original elements represented by the value at the * given <code>index</code> within this {@link UniqueList}. */ public List<E> getAll(int index) { int startIndex = getSourceIndex(index); int endIndex = getEndIndex(index); return new ArrayList<E>(source.subList(startIndex, endIndex)); }
/** * Returns a List of all original elements represented by the value at the * given <code>index</code> within this {@link UniqueList}. */ public List<E> getAll(int index) { int startIndex = getSourceIndex(index); int endIndex = getEndIndex(index); return new ArrayList<E>(source.subList(startIndex, endIndex)); }
/** * Returns a List of all original elements represented by the value at the * given <code>index</code> within this {@link UniqueList}. */ public List<E> getAll(int index) { int startIndex = getSourceIndex(index); int endIndex = getEndIndex(index); return new ArrayList<E>(source.subList(startIndex, endIndex)); }
/** * Get the first element that's not a duplicate of the element at the specified * index. This is useful for things like {@link #getCount(int)} because we can * find the full range of a value quickly. */ private int getEndIndex(int index) { if(index == (size() - 1)) return source.size(); else return getSourceIndex(index + 1); }
/** * Get the first element that's not a duplicate of the element at the specified * index. This is useful for things like {@link #getCount(int)} because we can * find the full range of a value quickly. */ private int getEndIndex(int index) { if(index == (size() - 1)) return source.size(); else return getSourceIndex(index + 1); }
/** * Get the first element that's not a duplicate of the element at the specified * index. This is useful for things like {@link #getCount(int)} because we can * find the full range of a value quickly. */ private int getEndIndex(int index) { if(index == (size() - 1)) return source.size(); else return getSourceIndex(index + 1); }
/** {@inheritDoc} */ @Override public E remove(int index) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot remove at " + index + " on list of size " + size()); updates.beginEvent(true); // remember the first duplicate E result = get(index); // remove all duplicates at this index int startIndex = getSourceIndex(index); int endIndex = getEndIndex(index); ((SortedList)source).subList(startIndex, endIndex).clear(); updates.commitEvent(); return result; }
/** {@inheritDoc} */ @Override public E remove(int index) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot remove at " + index + " on list of size " + size()); updates.beginEvent(true); // remember the first duplicate E result = get(index); // remove all duplicates at this index int startIndex = getSourceIndex(index); int endIndex = getEndIndex(index); ((SortedList)source).subList(startIndex, endIndex).clear(); updates.commitEvent(); return result; }
/** {@inheritDoc} */ @Override public E remove(int index) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot remove at " + index + " on list of size " + size()); updates.beginEvent(true); // remember the first duplicate E result = get(index); // remove all duplicates at this index int startIndex = getSourceIndex(index); int endIndex = getEndIndex(index); ((SortedList)source).subList(startIndex, endIndex).clear(); updates.commitEvent(); return result; }
/** {@inheritDoc} */ @Override public E set(int index, E value) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot set at " + index + " on list of size " + size()); updates.beginEvent(true); // remove all duplicates of this value first int startIndex = getSourceIndex(index) + 1; int endIndex = getEndIndex(index); if(endIndex > startIndex) { ((SortedList)source).subList(startIndex, endIndex).clear(); } // now do the set E result = super.set(index, value); updates.commitEvent(); return result; }
/** {@inheritDoc} */ @Override public E set(int index, E value) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot set at " + index + " on list of size " + size()); updates.beginEvent(true); // remove all duplicates of this value first int startIndex = getSourceIndex(index) + 1; int endIndex = getEndIndex(index); if(endIndex > startIndex) { ((SortedList)source).subList(startIndex, endIndex).clear(); } // now do the set E result = super.set(index, value); updates.commitEvent(); return result; }
/** {@inheritDoc} */ @Override public E set(int index, E value) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot set at " + index + " on list of size " + size()); updates.beginEvent(true); // remove all duplicates of this value first int startIndex = getSourceIndex(index) + 1; int endIndex = getEndIndex(index); if(endIndex > startIndex) { ((SortedList)source).subList(startIndex, endIndex).clear(); } // now do the set E result = super.set(index, value); updates.commitEvent(); return result; }