org.norther.tammi.acorn.util
Class StringKeyHashSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by org.norther.tammi.acorn.util.StringKeyHashSet
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, Set, OrderedSet

public class StringKeyHashSet
extends AbstractSet
implements OrderedSet, Cloneable, Serializable

An implementation of the OrderedSet interface applying string representations of set elements as keys in comparisons.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
StringKeyHashSet()
          Constructs a new set.
StringKeyHashSet(Collection c)
          Constructs a new set containing the elements in the specified collection.
StringKeyHashSet(int capacity)
          Constructs a new set with the specified capacity.
StringKeyHashSet(int capacity, float loadFactor)
          Constructs a new set with the specified capacity and load factor.
 
Method Summary
 boolean add(int index, Object value)
          Adds the specified element to the specified index in this set.
 boolean add(Object value)
           
 void clear()
           
 Object clone()
          Returns a shallow copy of this set.
 boolean contains(Object o)
           
 Object get(int index)
          Gets the indexed element in this set.
 int indexOf(Object value)
          Returns the index of the specified element, or -1 if not found.
 boolean isEmpty()
           
 boolean isModifiable()
          Checks whether this set is modifiable.
 Iterator iterator()
          Returns an ordered iterator over the elements in this set.
 ListIterator listIterator()
          Returns a list iterator over the elements in this set.
 ListIterator listIterator(int index)
          Returns a list iterator with a start index over the elements in this set.
 Object remove(int index)
          Removes the indexed element in this set.
 boolean remove(Object value)
           
 int size()
           
 List valueList()
          Returns an ordered list of set values.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, 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
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

StringKeyHashSet

public StringKeyHashSet()
Constructs a new set.


StringKeyHashSet

public StringKeyHashSet(Collection c)
Constructs a new set containing the elements in the specified collection.

Parameters:
c - an initial collection.

StringKeyHashSet

public StringKeyHashSet(int capacity)
Constructs a new set with the specified capacity.

Parameters:
capacity - the initial capacity.

StringKeyHashSet

public StringKeyHashSet(int capacity,
                        float loadFactor)
Constructs a new set with the specified capacity and load factor.

Parameters:
capacity - the initial capacity.
loadFactor - the load factor.
Method Detail

clone

public Object clone()
Returns a shallow copy of this set. The elements in the set are not cloned.

Overrides:
clone in class Object
Returns:
a shallow copy of this set.

isModifiable

public boolean isModifiable()
Description copied from interface: OrderedSet
Checks whether this set is modifiable.

Specified by:
isModifiable in interface OrderedSet
Returns:
true for a modifiable set, false otherwise.

indexOf

public int indexOf(Object value)
Description copied from interface: OrderedSet
Returns the index of the specified element, or -1 if not found.

Specified by:
indexOf in interface OrderedSet
Parameters:
value - the element.
Returns:
the index of the element.

get

public Object get(int index)
Description copied from interface: OrderedSet
Gets the indexed element in this set.

Specified by:
get in interface OrderedSet
Parameters:
index - the index.
Returns:
the indexed the element.

add

public boolean add(int index,
                   Object value)
Description copied from interface: OrderedSet
Adds the specified element to the specified index in this set. Note that an existing element is not moved.

Specified by:
add in interface OrderedSet
Parameters:
index - the index.
value - the element.
Returns:
true if added, false if already present.

add

public boolean add(Object value)
Specified by:
add in interface Collection
Specified by:
add in interface Set
Overrides:
add in class AbstractCollection

remove

public Object remove(int index)
Description copied from interface: OrderedSet
Removes the indexed element in this set.

Specified by:
remove in interface OrderedSet
Parameters:
index - the index.
Returns:
the removed value.

remove

public boolean remove(Object value)
Specified by:
remove in interface Collection
Specified by:
remove in interface Set
Overrides:
remove in class AbstractCollection

clear

public void clear()
Specified by:
clear in interface Collection
Specified by:
clear in interface Set
Overrides:
clear in class AbstractCollection

contains

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

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface Set
Overrides:
isEmpty in class AbstractCollection

size

public int size()
Specified by:
size in interface Collection
Specified by:
size in interface Set
Specified by:
size in class AbstractCollection

iterator

public Iterator iterator()
Description copied from interface: OrderedSet
Returns an ordered iterator over the elements in this set.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface Set
Specified by:
iterator in interface OrderedSet
Specified by:
iterator in class AbstractCollection
Returns:
an iterator.

listIterator

public ListIterator listIterator()
Description copied from interface: OrderedSet
Returns a list iterator over the elements in this set.

Specified by:
listIterator in interface OrderedSet
Returns:
a list iterator.

listIterator

public ListIterator listIterator(int index)
Description copied from interface: OrderedSet
Returns a list iterator with a start index over the elements in this set.

Specified by:
listIterator in interface OrderedSet
Parameters:
index - the start index.
Returns:
a list iterator.

valueList

public List valueList()
Description copied from interface: OrderedSet
Returns an ordered list of set values.

Specified by:
valueList in interface OrderedSet
Returns:
a list of values.


Copyright © 2004 The Norther Organization. All rights reserved.