Class ObjectRBTreeSet<K>
- All Implemented Interfaces:
ObjectBidirectionalIterable<K>
,ObjectCollection<K>
,ObjectIterable<K>
,ObjectSet<K>
,ObjectSortedSet<K>
,Serializable
,Cloneable
,Iterable<K>
,Collection<K>
,SequencedCollection<K>
,SequencedSet<K>
,Set<K>
,SortedSet<K>
The iterators provided by this class are type-specific
bidirectional iterators
. Moreover, the
iterator returned by iterator()
can be safely cast to a type-specific
list iterator.
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates a new empty tree set.ObjectRBTreeSet
(ObjectCollection<? extends K> c) Creates a new tree set copying a given type-specific collection.Creates a new tree set copying a given type-specific sorted set (and itsComparator
).ObjectRBTreeSet
(Collection<? extends K> c) Creates a new tree set copying a given collection.ObjectRBTreeSet
(Comparator<? super K> c) Creates a new empty tree set with the given comparator.ObjectRBTreeSet
(Iterator<? extends K> i) Creates a new tree set using elements provided by a type-specific iterator.Creates a new tree set copying a given sorted set (and itsComparator
).ObjectRBTreeSet
(K[] a) Creates a new tree set copying the elements of an array.ObjectRBTreeSet
(K[] a, int offset, int length) Creates a new tree set and fills it with the elements of a given array.ObjectRBTreeSet
(K[] a, int offset, int length, Comparator<? super K> c) Creates a new tree set and fills it with the elements of a given array using a givenComparator
.ObjectRBTreeSet
(K[] a, Comparator<? super K> c) Creates a new tree set copying the elements of an array using a givenComparator
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
clear()
clone()
Returns a deep copy of this tree set.Comparator
<? super K> boolean
first()
Returns a view of the portion of this sorted set whose elements are strictly less thantoElement
.boolean
isEmpty()
iterator()
Returns a type-specific iterator on the elements of this collection.Returns a type-specificBidirectionalIterator
on the elements in this set, starting from a given element of the domain (optional operation).last()
boolean
int
size()
Returns a view of the portion of this sorted set whose elements range fromfromElement
, inclusive, totoElement
, exclusive.Returns a view of the portion of this sorted set whose elements are greater than or equal tofromElement
.Methods inherited from class it.unimi.dsi.fastutil.objects.AbstractObjectSet
equals, hashCode
Methods inherited from class it.unimi.dsi.fastutil.objects.AbstractObjectCollection
toString
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, removeAll, retainAll, toArray, toArray
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface it.unimi.dsi.fastutil.objects.ObjectSortedSet
spliterator
Methods inherited from interface java.util.Set
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
Methods inherited from interface java.util.SortedSet
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, reversed
-
Constructor Details
-
ObjectRBTreeSet
public ObjectRBTreeSet()Creates a new empty tree set. -
ObjectRBTreeSet
Creates a new empty tree set with the given comparator.- Parameters:
c
- aComparator
(even better, a type-specific comparator).
-
ObjectRBTreeSet
Creates a new tree set copying a given collection.- Parameters:
c
- a collection to be copied into the new tree set.
-
ObjectRBTreeSet
Creates a new tree set copying a given sorted set (and itsComparator
).- Parameters:
s
- aSortedSet
to be copied into the new tree set.
-
ObjectRBTreeSet
Creates a new tree set copying a given type-specific collection.- Parameters:
c
- a type-specific collection to be copied into the new tree set.
-
ObjectRBTreeSet
Creates a new tree set copying a given type-specific sorted set (and itsComparator
).- Parameters:
s
- a type-specific sorted set to be copied into the new tree set.
-
ObjectRBTreeSet
Creates a new tree set using elements provided by a type-specific iterator.- Parameters:
i
- a type-specific iterator whose elements will fill the set.
-
ObjectRBTreeSet
Creates a new tree set and fills it with the elements of a given array using a givenComparator
.- Parameters:
a
- an array whose elements will be used to fill the set.offset
- the first element to use.length
- the number of elements to use.c
- aComparator
(even better, a type-specific comparator).
-
ObjectRBTreeSet
Creates a new tree set and fills it with the elements of a given array.- Parameters:
a
- an array whose elements will be used to fill the set.offset
- the first element to use.length
- the number of elements to use.
-
ObjectRBTreeSet
Creates a new tree set copying the elements of an array.- Parameters:
a
- an array to be copied into the new tree set.
-
ObjectRBTreeSet
Creates a new tree set copying the elements of an array using a givenComparator
.- Parameters:
a
- an array to be copied into the new tree set.c
- aComparator
(even better, a type-specific comparator).
-
-
Method Details
-
add
- Specified by:
add
in interfaceCollection<K>
- Specified by:
add
in interfaceSet<K>
- Overrides:
add
in classAbstractCollection<K>
-
remove
- Specified by:
remove
in interfaceCollection<K>
- Specified by:
remove
in interfaceSet<K>
- Overrides:
remove
in classAbstractCollection<K>
-
contains
- Specified by:
contains
in interfaceCollection<K>
- Specified by:
contains
in interfaceSet<K>
- Overrides:
contains
in classAbstractCollection<K>
-
get
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<K>
- Specified by:
clear
in interfaceSet<K>
- Overrides:
clear
in classAbstractCollection<K>
-
size
public int size()- Specified by:
size
in interfaceCollection<K>
- Specified by:
size
in interfaceSet<K>
- Specified by:
size
in classAbstractCollection<K>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<K>
- Specified by:
isEmpty
in interfaceSet<K>
- Overrides:
isEmpty
in classAbstractCollection<K>
-
first
-
last
-
iterator
Description copied from interface:ObjectCollection
Returns a type-specific iterator on the elements of this collection.- Specified by:
iterator
in interfaceCollection<K>
- Specified by:
iterator
in interfaceIterable<K>
- Specified by:
iterator
in interfaceObjectBidirectionalIterable<K>
- Specified by:
iterator
in interfaceObjectCollection<K>
- Specified by:
iterator
in interfaceObjectIterable<K>
- Specified by:
iterator
in interfaceObjectSet<K>
- Specified by:
iterator
in interfaceObjectSortedSet<K>
- Specified by:
iterator
in interfaceSet<K>
- Specified by:
iterator
in classAbstractObjectSortedSet<K>
- Returns:
- a type-specific iterator on the elements of this collection.
- See Also:
-
iterator
Description copied from interface:ObjectSortedSet
Returns a type-specificBidirectionalIterator
on the elements in this set, starting from a given element of the domain (optional operation).This method returns a type-specific bidirectional iterator with given starting point. The starting point is any element comparable to the elements of this set (even if it does not actually belong to the set). The next element of the returned iterator is the least element of the set that is greater than the starting point (if there are no elements greater than the starting point,
hasNext()
will returnfalse
). The previous element of the returned iterator is the greatest element of the set that is smaller than or equal to the starting point (if there are no elements smaller than or equal to the starting point,hasPrevious()
will returnfalse
).Note that passing the last element of the set as starting point and calling
previous()
you can traverse the entire set in reverse order.- Specified by:
iterator
in interfaceObjectSortedSet<K>
- Parameters:
from
- an element to start from.- Returns:
- a bidirectional iterator on the element in this set, starting at the given element.
-
comparator
- Specified by:
comparator
in interfaceSortedSet<K>
-
headSet
Description copied from interface:ObjectSortedSet
Returns a view of the portion of this sorted set whose elements are strictly less thantoElement
. -
tailSet
Description copied from interface:ObjectSortedSet
Returns a view of the portion of this sorted set whose elements are greater than or equal tofromElement
. -
subSet
Description copied from interface:ObjectSortedSet
Returns a view of the portion of this sorted set whose elements range fromfromElement
, inclusive, totoElement
, exclusive. -
clone
Returns a deep copy of this tree set.This method performs a deep copy of this tree set; the data stored in the set, however, is not cloned. Note that this makes a difference only for object keys.
- Returns:
- a deep copy of this tree set.
-