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:
- Serialized Form
|
Constructor Summary |
ArraySortedSet(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. |
ArraySortedSet
public ArraySortedSet(E[] values)
- Creates a set backed by an array. The array must be sorted, and is
not copied.
- Parameters:
values - Array of values
ArraySortedSet
public ArraySortedSet(E[] values,
int start,
int end)
- 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
iterator
public Iterator<E> iterator()
- Specified by:
iterator in interface Iterable<E extends Comparable<E>>- Specified by:
iterator in interface Collection<E extends Comparable<E>>- Specified by:
iterator in interface Set<E extends Comparable<E>>- Specified by:
iterator in class AbstractCollection<E extends Comparable<E>>
size
public int size()
- Specified by:
size in interface Collection<E extends Comparable<E>>- Specified by:
size in interface Set<E extends Comparable<E>>- Specified by:
size in class AbstractCollection<E extends Comparable<E>>
comparator
public Comparator<? super E> comparator()
- Specified by:
comparator in interface SortedSet<E extends Comparable<E>>
subSet
public SortedSet<E> subSet(E fromElement,
E toElement)
- Specified by:
subSet in interface SortedSet<E extends Comparable<E>>
headSet
public SortedSet<E> headSet(E toElement)
- Specified by:
headSet in interface SortedSet<E extends Comparable<E>>
tailSet
public SortedSet<E> tailSet(E fromElement)
- Specified by:
tailSet in interface SortedSet<E extends Comparable<E>>
first
public E first()
- Specified by:
first in interface SortedSet<E extends Comparable<E>>
last
public E last()
- Specified by:
last in interface SortedSet<E extends Comparable<E>>
toArray
public Object[] toArray()
- Specified by:
toArray in interface Collection<E extends Comparable<E>>- Specified by:
toArray in interface Set<E extends Comparable<E>>- Overrides:
toArray in class AbstractCollection<E extends Comparable<E>>
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray in interface Collection<E extends Comparable<E>>- Specified by:
toArray in interface Set<E extends Comparable<E>>- Overrides:
toArray in class AbstractCollection<E extends Comparable<E>>
merge
public ArraySortedSet<E> merge(ArraySortedSet<E> arrayToMerge)
- Performs a merge between two
ArraySortedSet instances
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:
Util.intersect(java.util.SortedSet, java.util.SortedSet)
contains
public boolean contains(Object o)
- Specified by:
contains in interface Collection<E extends Comparable<E>>- Specified by:
contains in interface Set<E extends Comparable<E>>- Overrides:
contains in class AbstractCollection<E extends Comparable<E>>