repthy
Class SingletonSortedSet

Object
  extended byAbstractCollection
      extended byAbstractSet
          extended byImmutableSet
              extended bySingletonSortedSet
All Implemented Interfaces:
Collection, Set, SortedSet

public class SingletonSortedSet
extends ImmutableSet
implements SortedSet

A singleton SortedSet, meaning a SortedSet with exactly one element. The set is immutable.

Author:
Mark McConnell

Constructor Summary
SingletonSortedSet(Object element)
          Constructor.
 
Method Summary
 Comparator comparator()
          Returns a dummy comparator in which the unique element of this set is always equal to itself.
 boolean contains(Object o)
           
 Object first()
           
 int hashCode()
           
 SortedSet headSet(Object to)
          Returns an empty SortedSet.
 boolean isEmpty()
           
 Iterator iterator()
           
 Object last()
           
 int size()
           
 SortedSet subSet(Object from, Object to)
          Returns an empty SortedSet.
 SortedSet tailSet(Object from)
          Returns this if from is the unique element of this set, and an empty SortedSet otherwise.
 
Methods inherited from class ImmutableSet
add, addAll, clear, remove, removeAll, retainAll
 
Methods inherited from class AbstractSet
equals
 
Methods inherited from class AbstractCollection
containsAll, toArray, toArray, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Set
add, addAll, clear, containsAll, equals, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

SingletonSortedSet

public SingletonSortedSet(Object element)
Constructor.

Parameters:
element - The unique element of this sorted set.
Throws:
NullPointerException - If element is null.
Method Detail

contains

public final boolean contains(Object o)
Specified by:
contains in interface Set

hashCode

public final int hashCode()
Specified by:
hashCode in interface Set

isEmpty

public final boolean isEmpty()
Specified by:
isEmpty in interface Set

iterator

public Iterator iterator()
Specified by:
iterator in interface Set

size

public final int size()
Specified by:
size in interface Set

first

public final Object first()
Specified by:
first in interface SortedSet

last

public final Object last()
Specified by:
last in interface SortedSet

comparator

public final Comparator comparator()
Returns a dummy comparator in which the unique element of this set is always equal to itself.

Specified by:
comparator in interface SortedSet

subSet

public SortedSet subSet(Object from,
                        Object to)
Returns an empty SortedSet.

Specified by:
subSet in interface SortedSet

headSet

public SortedSet headSet(Object to)
Returns an empty SortedSet.

Specified by:
headSet in interface SortedSet

tailSet

public SortedSet tailSet(Object from)
Returns this if from is the unique element of this set, and an empty SortedSet otherwise.

Specified by:
tailSet in interface SortedSet