Joda System API

org.joda.util
Class IdentityBasedHashSet

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractSet
              |
              +--org.joda.util.IdentityBasedHashSet
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.io.Serializable, java.util.Set

public class IdentityBasedHashSet
extends java.util.AbstractSet
implements java.lang.Cloneable, java.io.Serializable

Set based on Hash principles which check for equality, not equals. This is probably not terribly efficient!

Author:
Stephen Colebourne
See Also:
Serialized Form

Nested Class Summary
static class IdentityBasedHashSet.Entry
          Hash entry.
 
Constructor Summary
IdentityBasedHashSet()
          Constructs a new, empty set with a default capacity and load factor, which is 0.75.
IdentityBasedHashSet(java.util.Collection coll)
          Constructs a new set with the same mappings as the given map.
IdentityBasedHashSet(int initialCapacity)
          Constructs a new, empty map with the specified initial capacity and default load factor, which is 0.75.
IdentityBasedHashSet(int initialCapacity, float loadFactor)
          Constructs a new, empty set with the specified initial capacity and the specified load factor.
 
Method Summary
 boolean add(java.lang.Object obj)
          Adds the specified value to the set.
 void clear()
          Removes all values from this set.
 java.lang.Object clone()
          Returns a shallow copy of this set instance: the values themselves are not cloned.
 boolean contains(java.lang.Object obj)
          Returns true if this set contains the object.
 boolean isEmpty()
          Returns true if the size is 0.
 java.util.Iterator iterator()
          Get an iterator accross the set
 boolean remove(java.lang.Object key)
          Removes the mapping for this key from this map if present.
 int size()
          Returns the size of the set.
 
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, retainAll, toArray, toArray
 

Constructor Detail

IdentityBasedHashSet

public IdentityBasedHashSet(int initialCapacity,
                            float loadFactor)
Constructs a new, empty set with the specified initial capacity and the specified load factor.

Parameters:
initialCapacity - the initial capacity of the set.
loadFactor - the load factor of the set
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive.

IdentityBasedHashSet

public IdentityBasedHashSet(int initialCapacity)
Constructs a new, empty map with the specified initial capacity and default load factor, which is 0.75.

Parameters:
initialCapacity - the initial capacity of the HashMap.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero.

IdentityBasedHashSet

public IdentityBasedHashSet()
Constructs a new, empty set with a default capacity and load factor, which is 0.75.


IdentityBasedHashSet

public IdentityBasedHashSet(java.util.Collection coll)
Constructs a new set with the same mappings as the given map. The map is created with a capacity of twice the number of mappings in the given map or 11 (whichever is greater), and a default load factor, which is 0.75.

Method Detail

size

public int size()
Returns the size of the set.

Specified by:
size in interface java.util.Set
Specified by:
size in class java.util.AbstractCollection
Returns:
size

isEmpty

public boolean isEmpty()
Returns true if the size is 0.

Specified by:
isEmpty in interface java.util.Set
Overrides:
isEmpty in class java.util.AbstractCollection
Returns:
true if empty

contains

public boolean contains(java.lang.Object obj)
Returns true if this set contains the object.

Specified by:
contains in interface java.util.Set
Overrides:
contains in class java.util.AbstractCollection
Parameters:
obj - the object to check for
Returns:
true if Set contains object by identity

add

public boolean add(java.lang.Object obj)
Adds the specified value to the set.

Specified by:
add in interface java.util.Set
Overrides:
add in class java.util.AbstractCollection
Parameters:
obj - object to add
Returns:
true if object added

remove

public boolean remove(java.lang.Object key)
Removes the mapping for this key from this map if present.

Specified by:
remove in interface java.util.Set
Overrides:
remove in class java.util.AbstractCollection
Parameters:
key - key whose mapping is to be removed from the map.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key.

clear

public void clear()
Removes all values from this set.

Specified by:
clear in interface java.util.Set
Overrides:
clear in class java.util.AbstractCollection

clone

public java.lang.Object clone()
Returns a shallow copy of this set instance: the values themselves are not cloned.

Overrides:
clone in class java.lang.Object
Returns:
a shallow copy of this map.

iterator

public java.util.Iterator iterator()
Get an iterator accross the set

Specified by:
iterator in interface java.util.Set
Specified by:
iterator in class java.util.AbstractCollection

Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.