|
|||||||||
| Home >> All >> Util >> [ Collections overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
Util.Collections
Class LinearSet

java.lang.Objectjava.util.AbstractCollection
java.util.AbstractSet
Util.Collections.LinearSet
- All Implemented Interfaces:
- java.lang.Cloneable, java.util.Collection, java.lang.Iterable, java.io.Serializable, java.util.Set
- public class LinearSet
- extends java.util.AbstractSet
- implements java.lang.Cloneable, java.io.Serializable
- extends java.util.AbstractSet
LinearSet is a simplistic light-weight
Set designed for use when the number of entries is
small. It is backed by a List.
- Version:
- $Id: LinearSet.java,v 1.1 2003/03/05 08:26:27 joewhaley Exp $
| Field Summary | |
private ListFactory |
lf
|
private java.util.List |
list
|
| Constructor Summary | |
LinearSet()
Creates a LinearSet. |
|
LinearSet(int capacity)
Creates a LinearSet with given capacity. |
|
LinearSet(ListFactory lf)
Creates an empty LinearSet, using a
List generated by lf as the backing
store. |
|
LinearSet(ListFactory lf,
int capacity)
Creates an empty LinearSet with a given capacity,
using a List generated by lf as the
backing store. |
|
LinearSet(ListFactory lf,
java.util.Set set)
Creates an empty LinearSet, using a
List generated by lf as the backing
store, and fills it with the elements of set. |
|
LinearSet(java.util.Set set)
Creates a LinearSet, filling it with the elements
of set. |
|
| Method Summary | |
boolean |
add(java.lang.Object o)
Adds the specified element to the set if it is not already present (optional operation). |
boolean |
addAll(java.util.Collection c)
Adds all of the elements of the given collection to this set (optional operation). |
void |
clear()
Removes all elements from this set (optional operation). |
java.lang.Object |
clone()
This method may be called to create a new copy of the Object. |
java.lang.Object |
get(java.lang.Object o)
|
java.util.Iterator |
iterator()
Returns an iterator over the set. |
boolean |
remove(java.lang.Object o)
Removes the specified element from this set (optional operation). |
int |
size()
Returns the number of elements in the set. |
| Methods inherited from class java.util.AbstractSet |
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
contains, containsAll, isEmpty, 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 |
contains, containsAll, isEmpty, retainAll, toArray, toArray |
| Field Detail |
list
private java.util.List list
lf
private ListFactory lf
| Constructor Detail |
LinearSet
public LinearSet()
- Creates a
LinearSet. Uses anArrayListas the backing store.
LinearSet
public LinearSet(int capacity)
- Creates a
LinearSetwith given capacity. Uses anArrayListas the backing store.
LinearSet
public LinearSet(java.util.Set set)
- Creates a
LinearSet, filling it with the elements ofset. Uses anArrayListas the backing store.
LinearSet
public LinearSet(ListFactory lf)
- Creates an empty
LinearSet, using aListgenerated bylfas the backing store.
LinearSet
public LinearSet(ListFactory lf, int capacity)
- Creates an empty
LinearSetwith a given capacity, using aListgenerated bylfas the backing store.
LinearSet
public LinearSet(ListFactory lf, java.util.Set set)
- Creates an empty
LinearSet, using aListgenerated bylfas the backing store, and fills it with the elements ofset.
| Method Detail |
iterator
public java.util.Iterator iterator()
- Description copied from interface:
java.util.Set - Returns an iterator over the set. The iterator has no specific order,
unless further specified.
- Specified by:
iteratorin interfacejava.util.Set
size
public int size()
- Description copied from interface:
java.util.Set - Returns the number of elements in the set. If there are more
than Integer.MAX_VALUE mappings, return Integer.MAX_VALUE. This is
the cardinality of the set.
- Specified by:
sizein interfacejava.util.Set
add
public boolean add(java.lang.Object o)
- Description copied from interface:
java.util.Set - Adds the specified element to the set if it is not already present
(optional operation). In particular, the comparison algorithm is
o == null ? e == null : o.equals(e). Sets need not permit all values, and may document what exceptions will be thrown if a value is not permitted.- Specified by:
addin interfacejava.util.Set
addAll
public boolean addAll(java.util.Collection c)
- Description copied from interface:
java.util.Set - Adds all of the elements of the given collection to this set (optional
operation). If the argument is also a Set, this returns the mathematical
union of the two. The behavior is unspecified if the set is
modified while this is taking place.
- Specified by:
addAllin interfacejava.util.Set
remove
public boolean remove(java.lang.Object o)
- Description copied from interface:
java.util.Set - Removes the specified element from this set (optional operation). If
an element e exists,
o == null ? e == null : o.equals(e), it is removed from the set.- Specified by:
removein interfacejava.util.Set
clear
public void clear()
- Description copied from interface:
java.util.Set - Removes all elements from this set (optional operation). This set will
be empty afterwords, unless an exception occurs.
- Specified by:
clearin interfacejava.util.Set
get
public java.lang.Object get(java.lang.Object o)
clone
public java.lang.Object clone()
- Description copied from class:
java.lang.Object - This method may be called to create a new copy of the
Object. The typical behavior is as follows:
o == o.clone()is falseo.getClass() == o.clone().getClass()is trueo.equals(o)is true
However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>
Object.equals(Object)55 .If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.
Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.
All array types implement Cloneable, and override this method as follows (it should never fail):
public Object clone() { try { super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(e.getMessage()); } }
|
|||||||||
| Home >> All >> Util >> [ Collections overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC