A SortedSet implementation that holds a single element. This implementation also extends AbstractSet because ... why not? So, it can be instantiated under an AbstractCollection or Collection as well.
The use-case for this is to have a memory-efficient data-structure in situations where you are using a SortedSet
, say
as a member variable in a class, but know that in many occasions you would hold only a single element in the set. Its
behavior/properties are "documented" by the included unit-tests that validate/illustrate the behavior of every API of
the parent classes (SortedSet
, AbstractSet
, Set
).
The implementation assumes that the element stored in the SingletonSortedSet
implements
Comparable. For this reason it also implements
getElement()
and getElement(T element)
.
There is some good related information in this post on StackOverflow
This library is licensed under Eclipse Public License v2.0