Package com.cedarsoftware.io.util
Class SealableNavigableSet<E>
java.lang.Object
com.cedarsoftware.io.util.SealableNavigableSet<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,NavigableSet<E>,Set<E>,SortedSet<E>
SealableNavigableSet provides a NavigableSet or NavigableSet wrapper that can be 'sealed' and
'unsealed.' When sealed, the NavigableSet is mutable, when unsealed it is immutable (read-only).
The view methods iterator(), descendingIterator(), descendingSet(), subSet(), headSet(), and
tailSet(), return a view that honors the Supplier's sealed state. The sealed state can be
changed as often as needed.
NOTE: Please do not reformat this code as the current format makes it easy to see the overall structure.
NOTE: Please do not reformat this code as the current format makes it easy to see the overall structure.
- Author:
- John DeRegnaucourt
Copyright (c) Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
License
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Constructor Summary
ConstructorsConstructorDescriptionSealableNavigableSet(Collection<? extends E> col, Supplier<Boolean> sealedSupplier) Create a NavigableSealableSet.SealableNavigableSet(Comparator<? super E> comparator, Supplier<Boolean> sealedSupplier) Create a NavigableSealableSet.SealableNavigableSet(Supplier<Boolean> sealedSupplier) Create a NavigableSealableSet.SealableNavigableSet(NavigableSet<E> set, Supplier<Boolean> sealedSupplier) Use this constructor to wrap a NavigableSet (any kind of NavigableSet) and make it a SealableNavigableSet.SealableNavigableSet(SortedSet<E> set, Supplier<Boolean> sealedSupplier) Create a NavigableSealableSet. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends E> col) voidclear()Comparator<? super E>booleanbooleancontainsAll(Collection<?> col) booleanfirst()inthashCode()booleanisEmpty()iterator()last()pollLast()booleanbooleanremoveAll(Collection<?> col) booleanretainAll(Collection<?> col) intsize()Object[]toArray()<T1> T1[]toArray(T1[] a) toString()Methods 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.SortedSet
spliterator
-
Constructor Details
-
SealableNavigableSet
Create a NavigableSealableSet. Since a NavigableSet is not supplied, this will use a ConcurrentSkipListSet internally. If you want to use a TreeSet for example, use the SealableNavigableSet constructor that takes a NavigableSet and pass it the instance you want it to wrap.- Parameters:
sealedSupplier-Supplier<Boolean>that returns 'true' to indicate sealed, 'false' for mutable.
-
SealableNavigableSet
Create a NavigableSealableSet. Since a NavigableSet is not supplied, this will use a ConcurrentSkipListSet internally. If you want to use a TreeSet for example, use the SealableNavigableSet constructor that takes a NavigableSet and pass it the instance you want it to wrap.- Parameters:
comparator-ComparatorA comparison function, which imposes a total ordering on some collection of objects.sealedSupplier-Supplier<Boolean>that returns 'true' to indicate sealed, 'false' for mutable.
-
SealableNavigableSet
Create a NavigableSealableSet. Since NavigableSet is not supplied, the elements from the passed in Collection will be copied to an internal ConcurrentSkipListSet. If you want to use a TreeSet for example, use the SealableNavigableSet constructor that takes a NavigableSet and pass it the instance you want it to wrap.- Parameters:
col- Collection to supply initial elements. These are copied to an internal ConcurrentSkipListSet.sealedSupplier-Supplier<Boolean>that returns 'true' to indicate sealed, 'false' for mutable.
-
SealableNavigableSet
Create a NavigableSealableSet. Since NavigableSet is not supplied, the elements from the passed in SortedSet will be copied to an internal ConcurrentSkipListSet. If you want to use a TreeSet for example, use the SealableNavigableSet constructor that takes a NavigableSet and pass it the instance you want it to wrap.- Parameters:
set- SortedSet to supply initial elements. These are copied to an internal ConcurrentSkipListSet.sealedSupplier-Supplier<Boolean>that returns 'true' to indicate sealed, 'false' for mutable.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
toString
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>
-
comparator
- Specified by:
comparatorin interfaceSortedSet<E>
-
first
-
last
-
toArray
-
toArray
public <T1> T1[] toArray(T1[] a) -
lower
- Specified by:
lowerin interfaceNavigableSet<E>
-
floor
- Specified by:
floorin interfaceNavigableSet<E>
-
ceiling
- Specified by:
ceilingin interfaceNavigableSet<E>
-
higher
- Specified by:
higherin interfaceNavigableSet<E>
-
iterator
-
descendingIterator
- Specified by:
descendingIteratorin interfaceNavigableSet<E>
-
descendingSet
- Specified by:
descendingSetin interfaceNavigableSet<E>
-
subSet
-
subSet
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) - Specified by:
subSetin interfaceNavigableSet<E>
-
headSet
-
headSet
- Specified by:
headSetin interfaceNavigableSet<E>
-
tailSet
-
tailSet
- Specified by:
tailSetin interfaceNavigableSet<E>
-
add
-
addAll
-
clear
public void clear() -
remove
-
removeAll
-
retainAll
-
pollFirst
- Specified by:
pollFirstin interfaceNavigableSet<E>
-
pollLast
- Specified by:
pollLastin interfaceNavigableSet<E>
-