|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.limewire.collection.IdentityHashSet<E>
public class IdentityHashSet<E>
A set equivalent of IdentityHashMap.
IdentityHashSet<String> ihs = new IdentityHashSet<String>(4);
String s = new String("Abby");
ihs.add(s);
if(!ihs.add(s))
System.out.println("Already contained ("+ s + "); contents: " + ihs);
if(ihs.add("Abby"))
System.out.println("Was able to add a new String(\"Abby\") since it's a separate object.");
System.out.println("Contents: " + ihs);
ihs.add("Bob");
ihs.add("Chris");
ihs.add("Dan");
System.out.println("Size is: " + ihs.size() + " contents: " + ihs);
Output:
Already contained (Abby); contents: [Abby]
Was able to add a new String("Abby") since it's a separate object.
Contents: [Abby, Abby]
Size is: 5 contents: [Dan, Chris, Abby, Abby, Bob]
| Constructor Summary | |
|---|---|
IdentityHashSet()
Constructs a new, empty set; the backing IdentityHashMap instance has default initial capacity (16) and load factor (0.75). |
|
IdentityHashSet(Collection<? extends E> c)
Constructs a new set containing the elements in the specified collection. |
|
IdentityHashSet(int initialCapacity)
Constructs a new, empty set; the backing IdentityHashMap instance has the specified initial capacity and default load factor, which is 0.75. |
|
| Method Summary | |
|---|---|
boolean |
add(E o)
Adds the specified element to this set if it is not already present. |
void |
clear()
Removes all of the elements from this set. |
Object |
clone()
Returns a shallow copy of this IdentityHashSet instance: the elements themselves are not cloned. |
boolean |
contains(Object o)
Returns true if this set contains the specified element. |
boolean |
isEmpty()
Returns true if this set contains no elements. |
Iterator<E> |
iterator()
Returns an iterator over the elements in this set. |
boolean |
remove(Object o)
Removes the specified element from this set if it is present. |
int |
size()
Returns the number of elements in this set (its cardinality). |
| 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 |
|---|
public IdentityHashSet()
public IdentityHashSet(Collection<? extends E> c)
c - the collection whose elements are to be placed into this set.
NullPointerException - if the specified collection is null.public IdentityHashSet(int initialCapacity)
initialCapacity - the initial capacity of the hash table.
IllegalArgumentException - if the initial capacity is less
than zero.| Method Detail |
|---|
public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface Set<E>iterator in class AbstractCollection<E>ConcurrentModificationExceptionpublic int size()
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>o - element whose presence in this set is to be tested.
public boolean add(E o)
add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>o - element to be added to this set.
public boolean remove(Object o)
remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>o - object to be removed from this set, if present.
public void clear()
clear in interface Collection<E>clear in interface Set<E>clear in class AbstractCollection<E>
public Object clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedException
|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||