Package mondrian.util
Class ArraySortedSet<E extends Comparable<E>>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
mondrian.util.ArraySortedSet<E>
- Type Parameters:
E-
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,Set<E>,SortedSet<E>
public class ArraySortedSet<E extends Comparable<E>>
extends AbstractSet<E>
implements SortedSet<E>, Serializable
Implementation of
SortedSet based on an array. The array
must already be sorted in natural order.- Author:
- Julian Hyde
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionArraySortedSet(E[] values) Creates a set backed by an array.ArraySortedSet(E[] values, int start, int end) Creates a set backed by a region of an array. -
Method Summary
Modifier and TypeMethodDescriptionComparator<? super E>booleanfirst()iterator()last()merge(ArraySortedSet<E> arrayToMerge) Performs a merge between twoArraySortedSetinstances in O(n) time, returning a third instance that doesn't include duplicates.intsize()Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
add, addAll, clear, containsAll, isEmpty, remove, retainAll, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
add, addAll, clear, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAllMethods inherited from interface java.util.SortedSet
spliterator
-
Constructor Details
-
ArraySortedSet
Creates a set backed by an array. The array must be sorted, and is not copied.- Parameters:
values- Array of values
-
ArraySortedSet
Creates a set backed by a region of an array. The array must be sorted, and is not copied.- Parameters:
values- Array of valuesstart- Index of start of regionend- Index of first element after end of region
-
-
Method Details
-
iterator
- Specified by:
iteratorin interfaceCollection<E extends Comparable<E>>- Specified by:
iteratorin interfaceIterable<E extends Comparable<E>>- Specified by:
iteratorin interfaceSet<E extends Comparable<E>>- Specified by:
iteratorin classAbstractCollection<E extends Comparable<E>>
-
size
public int size()- Specified by:
sizein interfaceCollection<E extends Comparable<E>>- Specified by:
sizein interfaceSet<E extends Comparable<E>>- Specified by:
sizein classAbstractCollection<E extends Comparable<E>>
-
comparator
- Specified by:
comparatorin interfaceSortedSet<E extends Comparable<E>>
-
subSet
- Specified by:
subSetin interfaceSortedSet<E extends Comparable<E>>
-
headSet
- Specified by:
headSetin interfaceSortedSet<E extends Comparable<E>>
-
tailSet
- Specified by:
tailSetin interfaceSortedSet<E extends Comparable<E>>
-
first
- Specified by:
firstin interfaceSortedSet<E extends Comparable<E>>
-
last
- Specified by:
lastin interfaceSortedSet<E extends Comparable<E>>
-
toArray
- Specified by:
toArrayin interfaceCollection<E extends Comparable<E>>- Specified by:
toArrayin interfaceSet<E extends Comparable<E>>- Overrides:
toArrayin classAbstractCollection<E extends Comparable<E>>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<E extends Comparable<E>>- Specified by:
toArrayin interfaceSet<E extends Comparable<E>>- Overrides:
toArrayin classAbstractCollection<E extends Comparable<E>>
-
merge
Performs a merge between twoArraySortedSetinstances in O(n) time, returning a third instance that doesn't include duplicates.For example, ArraySortedSet("a", "b", "c").merge(ArraySortedSet("a", "c", "e")) returns ArraySortedSet("a", "b", "c", "e")}.
- Parameters:
arrayToMerge- Other set to combine with this- Returns:
- Set containing union of the elements of inputs
- See Also:
-
contains
- Specified by:
containsin interfaceCollection<E extends Comparable<E>>- Specified by:
containsin interfaceSet<E extends Comparable<E>>- Overrides:
containsin classAbstractCollection<E extends Comparable<E>>
-