Package net.i2p.util
Class UnmodifiableSortedSet<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
net.i2p.util.ArraySet<E>
net.i2p.util.UnmodifiableSortedSet<E>
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
,SortedSet<E>
Efficient implementation of a SortedSet stored in a fixed-size array.
Much more space-efficient than TreeSet.
Doesn't do copying like CopyOnWriteArraySet.
Unmodifiable, thread-safe.
Null elements are not permitted.
The Collection constructors are not recommended for large sets
as the duplicate check is O(n**2).
- Since:
- 0.9.55
-
Nested Class Summary
Nested classes/interfaces inherited from class net.i2p.util.ArraySet
ArraySet.SetFullException
-
Field Summary
Fields inherited from class net.i2p.util.ArraySet
_entries, MAX_CAPACITY
-
Constructor Summary
ConstructorDescriptionUnmodifiableSortedSet
(Collection<? extends E> c) Warning: O(n**2)UnmodifiableSortedSet
(Collection<? extends E> c, Comparator<? super E> comparator) Warning: O(n**2)UnmodifiableSortedSet
(Set<? extends E> c) UnmodifiableSortedSet
(Set<? extends E> c, Comparator<? super E> comparator) UnmodifiableSortedSet
(SortedSet<? extends E> c) UnmodifiableSortedSet
(SortedSet<? extends E> c, Comparator<? super E> comparator) -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
Unconditionally add o to the set.void
clear()
Comparator<? super E>
first()
protected int
Overridden to do binary searchlast()
boolean
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
addAll, contains, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray
Methods inherited from interface java.util.SortedSet
spliterator
-
Constructor Details
-
UnmodifiableSortedSet
-
UnmodifiableSortedSet
-
UnmodifiableSortedSet
-
UnmodifiableSortedSet
-
UnmodifiableSortedSet
Warning: O(n**2) -
UnmodifiableSortedSet
Warning: O(n**2)
-
-
Method Details
-
comparator
- Specified by:
comparator
in interfaceSortedSet<E>
-
first
-
last
-
headSet
- Specified by:
headSet
in interfaceSortedSet<E>
- Throws:
UnsupportedOperationException
-
subSet
- Specified by:
subSet
in interfaceSortedSet<E>
- Throws:
UnsupportedOperationException
-
tailSet
- Specified by:
tailSet
in interfaceSortedSet<E>
- Throws:
UnsupportedOperationException
-
add
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classArraySet<E>
- Throws:
UnsupportedOperationException
-
addUnique
Description copied from class:ArraySet
Unconditionally add o to the set. This avoids the O(n) time of add(), but it's the caller's responsibility to ensure that o is not a duplicate. Any duplicate added will appear in the iterator.- Overrides:
addUnique
in classArraySet<E>
- Parameters:
o
- non-null, NPE will not be thrown- Throws:
UnsupportedOperationException
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- Overrides:
clear
in classArraySet<E>
- Throws:
UnsupportedOperationException
-
remove
- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
- Overrides:
remove
in classArraySet<E>
- Throws:
UnsupportedOperationException
-
indexOf
Overridden to do binary search
-