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 TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends E> col) void
clear()
Comparator<? super E>
boolean
boolean
containsAll
(Collection<?> col) boolean
first()
int
hashCode()
boolean
isEmpty()
iterator()
last()
pollLast()
boolean
boolean
removeAll
(Collection<?> col) boolean
retainAll
(Collection<?> col) int
size()
Object[]
toArray()
<T1> T1[]
toArray
(T1[] a) 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.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
-Comparator
A 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:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
-
comparator
- Specified by:
comparator
in interfaceSortedSet<E>
-
first
-
last
-
toArray
-
toArray
public <T1> T1[] toArray(T1[] a) -
lower
- Specified by:
lower
in interfaceNavigableSet<E>
-
floor
- Specified by:
floor
in interfaceNavigableSet<E>
-
ceiling
- Specified by:
ceiling
in interfaceNavigableSet<E>
-
higher
- Specified by:
higher
in interfaceNavigableSet<E>
-
iterator
-
descendingIterator
- Specified by:
descendingIterator
in interfaceNavigableSet<E>
-
descendingSet
- Specified by:
descendingSet
in interfaceNavigableSet<E>
-
subSet
-
subSet
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) - Specified by:
subSet
in interfaceNavigableSet<E>
-
headSet
-
headSet
- Specified by:
headSet
in interfaceNavigableSet<E>
-
tailSet
-
tailSet
- Specified by:
tailSet
in interfaceNavigableSet<E>
-
add
-
addAll
-
clear
public void clear() -
remove
-
removeAll
-
retainAll
-
pollFirst
- Specified by:
pollFirst
in interfaceNavigableSet<E>
-
pollLast
- Specified by:
pollLast
in interfaceNavigableSet<E>
-