/** * Returns the number of {@link ValueSegment}s which appear between the * given <code>start</code> and <code>end</code> values. */ public int getCount(V start, V end) { final int numStartedBeforeSegmentEnd = this.start.indexOfValue(end, true, true, (byte)1); final int numEndedBeforeSegmentStart = this.end.indexOfValue(start, true, true, (byte)1); return numStartedBeforeSegmentEnd - numEndedBeforeSegmentStart; }
/** * Returns the number of {@link ValueSegment}s which appear between the * given <code>start</code> and <code>end</code> values. */ public int getCount(V start, V end) { final int numStartedBeforeSegmentEnd = this.start.indexOfValue(end, true, true, (byte)1); final int numEndedBeforeSegmentStart = this.end.indexOfValue(start, true, true, (byte)1); return numStartedBeforeSegmentEnd - numEndedBeforeSegmentStart; }
/** * Returns the number of {@link ValueSegment}s which appear between the * given <code>start</code> and <code>end</code> values. */ public int getCount(V start, V end) { final int numStartedBeforeSegmentEnd = this.start.indexOfValue(end, true, true, (byte)1); final int numEndedBeforeSegmentStart = this.end.indexOfValue(start, true, true, (byte)1); return numStartedBeforeSegmentEnd - numEndedBeforeSegmentStart; }
/** * Returns the first index of the <code>object</code>'s sort location or * the first index at which the <code>object</code> could be positioned if * inserted. * * <p>Unlike {@link #indexOf} this method does not guarantee the given * <code>object</code> {@link Object#equals(Object) equals} the element at * the returned index. Instead, they are indistinguishable according to the * sorting {@link Comparator}. * * @return a value in <tt>[0, size()]</tt> inclusive */ public int sortIndex(Object object) { if (comparator == null) throw new IllegalStateException("No Comparator exists to perform this operation"); return ((SimpleTree)sorted).indexOfValue(object, true, true, ALL_COLORS); }
/** * Returns the last index of the <code>object</code>'s sort location or * the last index at which the <code>object</code> could be positioned if * inserted. * * <p>Unlike {@link #lastIndexOf} this method does not guarantee the given * <code>object</code> {@link Object#equals(Object) equals} the element at * the returned index. Instead, they are indistinguishable according to the * sorting {@link Comparator}. * * @return a value in <tt>[0, size()]</tt> inclusive */ public int lastSortIndex(Object object) { if (comparator == null) throw new IllegalStateException("No Comparator exists to perform this operation"); return ((SimpleTree)sorted).indexOfValue(object, false, true, ALL_COLORS); }
/** * Returns the first index of the <code>object</code>'s sort location or * the first index at which the <code>object</code> could be positioned if * inserted. * * <p>Unlike {@link #indexOf} this method does not guarantee the given * <code>object</code> {@link Object#equals(Object) equals} the element at * the returned index. Instead, they are indistinguishable according to the * sorting {@link Comparator}. * * @return a value in <tt>[0, size()]</tt> inclusive */ public int sortIndex(Object object) { if (comparator == null) throw new IllegalStateException("No Comparator exists to perform this operation"); return ((SimpleTree)sorted).indexOfValue(object, true, true, ALL_COLORS); }
/** * Returns the first index of the <code>object</code>'s sort location or * the first index at which the <code>object</code> could be positioned if * inserted. * * <p>Unlike {@link #indexOf} this method does not guarantee the given * <code>object</code> {@link Object#equals(Object) equals} the element at * the returned index. Instead, they are indistinguishable according to the * sorting {@link Comparator}. * * @return a value in <tt>[0, size()]</tt> inclusive */ public int sortIndex(Object object) { if (comparator == null) throw new IllegalStateException("No Comparator exists to perform this operation"); return ((SimpleTree)sorted).indexOfValue(object, true, true, ALL_COLORS); }
/** * Returns the last index of the <code>object</code>'s sort location or * the last index at which the <code>object</code> could be positioned if * inserted. * * <p>Unlike {@link #lastIndexOf} this method does not guarantee the given * <code>object</code> {@link Object#equals(Object) equals} the element at * the returned index. Instead, they are indistinguishable according to the * sorting {@link Comparator}. * * @return a value in <tt>[0, size()]</tt> inclusive */ public int lastSortIndex(Object object) { if (comparator == null) throw new IllegalStateException("No Comparator exists to perform this operation"); return ((SimpleTree)sorted).indexOfValue(object, false, true, ALL_COLORS); }
/** * Returns the last index of the <code>object</code>'s sort location or * the last index at which the <code>object</code> could be positioned if * inserted. * * <p>Unlike {@link #lastIndexOf} this method does not guarantee the given * <code>object</code> {@link Object#equals(Object) equals} the element at * the returned index. Instead, they are indistinguishable according to the * sorting {@link Comparator}. * * @return a value in <tt>[0, size()]</tt> inclusive */ public int lastSortIndex(Object object) { if (comparator == null) throw new IllegalStateException("No Comparator exists to perform this operation"); return ((SimpleTree)sorted).indexOfValue(object, false, true, ALL_COLORS); }
/** * Returns the index in this list of the first occurrence of the specified * element, or the index where that element would be in the list if it were * inserted. * * @return the index in this list of the first occurrence of the specified * element, or the index where that element would be in the list if it * were inserted. This will return a value in <tt>[0, size()]</tt>, * inclusive. * * @deprecated Deprecated as of 12/11/2005. Replaced with {@link #sortIndex(Object)} * which has cleaner semantics. */ public int indexOfSimulated(Object object) { return comparator != null ? ((SimpleTree)sorted).indexOfValue(object, true, true, ALL_COLORS) : size(); }
/** * Returns the index in this list of the first occurrence of the specified * element, or the index where that element would be in the list if it were * inserted. * * @return the index in this list of the first occurrence of the specified * element, or the index where that element would be in the list if it * were inserted. This will return a value in <tt>[0, size()]</tt>, * inclusive. * * @deprecated Deprecated as of 12/11/2005. Replaced with {@link #sortIndex(Object)} * which has cleaner semantics. */ @Deprecated public int indexOfSimulated(Object object) { return comparator != null ? ((SimpleTree)sorted).indexOfValue(object, true, true, ALL_COLORS) : size(); }
/** * Returns the index in this list of the first occurrence of the specified * element, or the index where that element would be in the list if it were * inserted. * * @return the index in this list of the first occurrence of the specified * element, or the index where that element would be in the list if it * were inserted. This will return a value in <tt>[0, size()]</tt>, * inclusive. * * @deprecated Deprecated as of 12/11/2005. Replaced with {@link #sortIndex(Object)} * which has cleaner semantics. */ public int indexOfSimulated(Object object) { return comparator != null ? ((SimpleTree)sorted).indexOfValue(object, true, true, ALL_COLORS) : size(); }
/** * Removes the <code>segment</code> from the trees. */ public void delete(ValueSegment<V,?> segment) { int startIndex = start.indexOfValue(segment.getStart(), true, false, (byte)1); int endIndex = end.indexOfValue(segment.getEnd(), true, false, (byte)1); start.remove(startIndex, 1); end.remove(endIndex, 1); }
/** * Removes the <code>segment</code> from the trees. */ public void delete(ValueSegment<V,?> segment) { int startIndex = start.indexOfValue(segment.getStart(), true, false, (byte)1); int endIndex = end.indexOfValue(segment.getEnd(), true, false, (byte)1); start.remove(startIndex, 1); end.remove(endIndex, 1); }
/** * Removes the <code>segment</code> from the trees. */ public void delete(ValueSegment<V,?> segment) { int startIndex = start.indexOfValue(segment.getStart(), true, false, (byte)1); int endIndex = end.indexOfValue(segment.getEnd(), true, false, (byte)1); start.remove(startIndex, 1); end.remove(endIndex, 1); }
/** {@inheritDoc} */ @Override public int lastIndexOf(Object object) { if(mode != STRICT_SORT_ORDER || comparator == null) return source.lastIndexOf(object); // use the fact that we have sorted data to quickly locate a position // at which we can begin a linear search for an object that .equals(object) int index = ((SimpleTree)sorted).indexOfValue(object, false, false, ALL_COLORS); // if we couldn't use the comparator to find the index, return -1 if (index == -1) return -1; // otherwise, we must now begin a linear search for the index of an element // that .equals() the given object for(; index > -1; index--) { E objectAtIndex = get(index); // if the objectAtIndex no longer compares equally with the given object, stop the linear search if(comparator.compare((E)object, objectAtIndex) != 0) return -1; // if the objectAtIndex and object are equal, return the index if(GlazedListsImpl.equal(object, objectAtIndex)) return index; } // if we fall out of the loop we could not locate the object return -1; }
/** {@inheritDoc} */ @Override public int lastIndexOf(Object object) { if(mode != STRICT_SORT_ORDER || comparator == null) return super.lastIndexOf(object); // use the fact that we have sorted data to quickly locate a position // at which we can begin a linear search for an object that .equals(object) int index = ((SimpleTree)sorted).indexOfValue(object, false, false, ALL_COLORS); // if we couldn't use the comparator to find the index, return -1 if (index == -1) return -1; // otherwise, we must now begin a linear search for the index of an element // that .equals() the given object for(; index > -1; index--) { E objectAtIndex = get(index); // if the objectAtIndex no longer compares equally with the given object, stop the linear search if(comparator.compare((E)object, objectAtIndex) != 0) return -1; // if the objectAtIndex and object are equal, return the index if(GlazedListsImpl.equal(object, objectAtIndex)) return index; } // if we fall out of the loop we could not locate the object return -1; }
/** {@inheritDoc} */ @Override public int lastIndexOf(Object object) { if(mode != STRICT_SORT_ORDER || comparator == null) return super.lastIndexOf(object); // use the fact that we have sorted data to quickly locate a position // at which we can begin a linear search for an object that .equals(object) int index = ((SimpleTree)sorted).indexOfValue(object, false, false, ALL_COLORS); // if we couldn't use the comparator to find the index, return -1 if (index == -1) return -1; // otherwise, we must now begin a linear search for the index of an element // that .equals() the given object for(; index > -1; index--) { E objectAtIndex = get(index); // if the objectAtIndex no longer compares equally with the given object, stop the linear search if(comparator.compare((E)object, objectAtIndex) != 0) return -1; // if the objectAtIndex and object are equal, return the index if(GlazedListsImpl.equal(object, objectAtIndex)) return index; } // if we fall out of the loop we could not locate the object return -1; }
/** {@inheritDoc} */ @Override public int indexOf(Object object) { if(mode != STRICT_SORT_ORDER || comparator == null) return super.indexOf(object); // use the fact that we have sorted data to quickly locate a position // at which we can begin a linear search for an object that .equals(object) int index = ((SimpleTree)sorted).indexOfValue(object, true, false, ALL_COLORS); // if we couldn't use the comparator to find the index, return -1 if (index == -1) return -1; // otherwise, we must now begin a linear search for the index of an element // that .equals() the given object for (; index < size(); index++) { E objectAtIndex = get(index); // if the objectAtIndex no longer compares equally with the given object, stop the linear search if (comparator.compare((E)object, objectAtIndex) != 0) return -1; // if the objectAtIndex and object are equal, return the index if (GlazedListsImpl.equal(object, objectAtIndex)) return index; } // if we fall out of the loop we could not locate the object return -1; }
/** {@inheritDoc} */ @Override public int indexOf(Object object) { if(mode != STRICT_SORT_ORDER || comparator == null) return super.indexOf(object); // use the fact that we have sorted data to quickly locate a position // at which we can begin a linear search for an object that .equals(object) int index = ((SimpleTree)sorted).indexOfValue(object, true, false, ALL_COLORS); // if we couldn't use the comparator to find the index, return -1 if (index == -1) return -1; // otherwise, we must now begin a linear search for the index of an element // that .equals() the given object for (; index < size(); index++) { E objectAtIndex = get(index); // if the objectAtIndex no longer compares equally with the given object, stop the linear search if (comparator.compare((E)object, objectAtIndex) != 0) return -1; // if the objectAtIndex and object are equal, return the index if (GlazedListsImpl.equal(object, objectAtIndex)) return index; } // if we fall out of the loop we could not locate the object return -1; }