jpaul.DataStructs
Class ArraySet<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<T>
jpaul.DataStructs.ArraySet<T>
- All Implemented Interfaces:
- java.lang.Iterable<T>, java.util.Collection<T>, java.util.Set<T>
public class ArraySet<T>
- extends java.util.AbstractSet<T>
ArraySet is an immutable, array-backed set. It
consumes minimal memory; very good for small sets.
- Version:
- $Id: ArraySet.java,v 1.2 2005/12/07 23:58:16 salcianu Exp $
- Author:
- Alex Salcianu - salcianu@alum.mit.edu
|
Constructor Summary |
ArraySet(java.util.Collection<T> coll)
Creates an ArraySet containing the distinct
elements from the colection coll. |
ArraySet(java.util.Collection<T> coll,
boolean collHasDistinctElements)
Powerful and unsafe constructor: creates an
ArraySet containing the distinct elements present
in the colection coll. |
ArraySet(java.util.Set<T> set)
Creates an ArraySet containing the elements
present in the set set. |
| Methods inherited from class java.util.AbstractSet |
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray |
ArraySet
public ArraySet(java.util.Set<T> set)
- Creates an
ArraySet containing the elements
present in the set set. The created
ArraySet contains the elements of
set at the point this constructor is invoked;
future changes to set are not reflected by the
ArraySet.
ArraySet
public ArraySet(java.util.Collection<T> coll)
- Creates an
ArraySet containing the distinct
elements from the colection coll. The created
ArraySet contains the elements of
set at the point this constructor is invoked;
future changes to set are not reflected by the
ArraySet.
ArraySet
public ArraySet(java.util.Collection<T> coll,
boolean collHasDistinctElements)
- Powerful and unsafe constructor: creates an
ArraySet containing the distinct elements present
in the colection coll. If the second parameter
collHasDistinctElements is true,
then this constructor assumes that coll contains
only distinct elements and skips the costly step of
determining the unique elements from
coll. This feature is unsafe and should
be used with maximal care!.
The created ArraySet contains the elements of
coll at the point this constructor is invoked;
future changes to coll are not reflected by the
ArraySet.
contains
public boolean contains(java.lang.Object o)
- Specified by:
contains in interface java.util.Collection<T>- Specified by:
contains in interface java.util.Set<T>- Overrides:
contains in class java.util.AbstractCollection<T>
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator in interface java.lang.Iterable<T>- Specified by:
iterator in interface java.util.Collection<T>- Specified by:
iterator in interface java.util.Set<T>- Specified by:
iterator in class java.util.AbstractCollection<T>
size
public int size()
- Specified by:
size in interface java.util.Collection<T>- Specified by:
size in interface java.util.Set<T>- Specified by:
size in class java.util.AbstractCollection<T>
Copyright 2005 Alexandru Salcianu - salcianu@alum.mit.edu