ca.quine.jcommons.transform.set
Class PositiveIntegerMultiTreeSet

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractSet
              |
              +--java.util.TreeSet
                    |
                    +--ca.quine.jcommons.transform.set.PositiveIntegerMultiTreeSet
All Implemented Interfaces:
Cloneable, Collection, Serializable, Set, SortedSet

public class PositiveIntegerMultiTreeSet
extends TreeSet

A multi-TreeSet that holds only Integer objects and uses multiplication instead of addition to form the hashCode(). The "multi" part means that the same number can be stored more than once in the set.

The primary use of this class will be to hold a set of Integers, and we will have many sets, all of which will add up to the same number.

In other words, the default hashCode() will return the same result for all sets. Since we intend to store all of them in a HashSet, that behaviour is obviously undesirable.

See Also:
Serialized Form

Constructor Summary
PositiveIntegerMultiTreeSet()
           
PositiveIntegerMultiTreeSet(SortedSet sortedSet)
           
PositiveIntegerMultiTreeSet(String stringList)
           
 
Method Summary
 boolean add(int i)
           
 boolean add(Object o)
           
 boolean contains(Object o)
           
 Object first()
           
 int hashCode()
           
 SortedSet headSet(Object toElement)
           
 Iterator iterator()
           
 Object last()
           
 boolean remove(Object o)
           
 int size()
           
 SortedSet subSet(Object fromElement, Object toElement)
           
 SortedSet tailSet(Object fromElement)
           
 
Methods inherited from class java.util.TreeSet
addAll, clear, clone, comparator, isEmpty
 
Methods inherited from class java.util.AbstractSet
equals, removeAll
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, equals, removeAll, retainAll, toArray, toArray
 

Constructor Detail

PositiveIntegerMultiTreeSet

public PositiveIntegerMultiTreeSet()

PositiveIntegerMultiTreeSet

public PositiveIntegerMultiTreeSet(SortedSet sortedSet)

PositiveIntegerMultiTreeSet

public PositiveIntegerMultiTreeSet(String stringList)
Method Detail

add

public boolean add(int i)

add

public boolean add(Object o)
Specified by:
add in interface Set
Overrides:
add in class TreeSet

hashCode

public int hashCode()
Specified by:
hashCode in interface Set
Overrides:
hashCode in class AbstractSet

iterator

public Iterator iterator()
Specified by:
iterator in interface Set
Overrides:
iterator in class TreeSet

headSet

public SortedSet headSet(Object toElement)
Specified by:
headSet in interface SortedSet
Overrides:
headSet in class TreeSet

tailSet

public SortedSet tailSet(Object fromElement)
Specified by:
tailSet in interface SortedSet
Overrides:
tailSet in class TreeSet

contains

public boolean contains(Object o)
Specified by:
contains in interface Set
Overrides:
contains in class TreeSet

first

public Object first()
Specified by:
first in interface SortedSet
Overrides:
first in class TreeSet

last

public Object last()
Specified by:
last in interface SortedSet
Overrides:
last in class TreeSet

remove

public boolean remove(Object o)
Specified by:
remove in interface Set
Overrides:
remove in class TreeSet

size

public int size()
Specified by:
size in interface Set
Overrides:
size in class TreeSet

subSet

public SortedSet subSet(Object fromElement,
                        Object toElement)
Specified by:
subSet in interface SortedSet
Overrides:
subSet in class TreeSet