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>,SequencedCollection<E>,SequencedSet<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
ConstructorsConstructorDescriptionUnmodifiableSortedSet(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 TypeMethodDescriptionbooleanvoidUnconditionally add o to the set.voidclear()Comparator<? super E> first()protected intOverridden to do binary searchlast()booleanMethods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, 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
addAll, contains, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArrayMethods inherited from interface java.util.SortedSet
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, reversed, spliterator
-
Constructor Details
-
UnmodifiableSortedSet
-
UnmodifiableSortedSet
-
UnmodifiableSortedSet
-
UnmodifiableSortedSet
-
UnmodifiableSortedSet
Warning: O(n**2) -
UnmodifiableSortedSet
Warning: O(n**2)
-
-
Method Details
-
comparator
- Specified by:
comparatorin interfaceSortedSet<E>
-
first
-
last
-
headSet
- Specified by:
headSetin interfaceSortedSet<E>- Throws:
UnsupportedOperationException
-
subSet
- Specified by:
subSetin interfaceSortedSet<E>- Throws:
UnsupportedOperationException
-
tailSet
- Specified by:
tailSetin interfaceSortedSet<E>- Throws:
UnsupportedOperationException
-
add
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classArraySet<E>- Throws:
UnsupportedOperationException
-
addUnique
Description copied from class:ArraySetUnconditionally 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:
addUniquein classArraySet<E>- Parameters:
o- non-null, NPE will not be thrown- Throws:
UnsupportedOperationException
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Overrides:
clearin classArraySet<E>- Throws:
UnsupportedOperationException
-
remove
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classArraySet<E>- Throws:
UnsupportedOperationException
-
indexOf
Overridden to do binary search
-