tyrex.util

Class ArraySet

public class ArraySet extends AbstractSet

Implementation of a simple Set based on an array. Does not allow multiple entries, does not support null entries.
Nested Class Summary
protected classArraySet.ArraySetIterator
AbstractSet requires an implementation for the iterator.
Field Summary
protected Object[]_table
The table of all objects in this set.
Constructor Summary
ArraySet()
Construct a new empty set.
ArraySet(Collection collection)
Construct a new set from the specified set and linked to a subject.
Method Summary
booleanadd(Object obj)
booleanaddAll(Collection collection)
Add the items from the specified collection to the set.
protected booleancanAdd(Object object)
Return true if the specified argument can be added to the set.
protected Objectget(int index)
Returns the element at the specified index, or null if the index is out of bounds.
Iteratoriterator()
booleanremove(Object obj)
intsize()

Field Detail

_table

protected Object[] _table
The table of all objects in this set.

Constructor Detail

ArraySet

public ArraySet()
Construct a new empty set.

ArraySet

public ArraySet(Collection collection)
Construct a new set from the specified set and linked to a subject. The subject is used to assure the set is not modifiable if the subject is set to read only. The type is optional, if specified the set will only contain elements of the specified type.

Parameters: subject the subject type the type set the set used to populate the created set

Method Detail

add

public boolean add(Object obj)

addAll

public boolean addAll(Collection collection)
Add the items from the specified collection to the set.

Parameters: collection the collection

Returns: True if items from the specified collection were added to the set.

canAdd

protected boolean canAdd(Object object)
Return true if the specified argument can be added to the set.

The default implementation returns true.

Parameters: object the object

Returns: true if the specified argument can be added to the set.

get

protected Object get(int index)
Returns the element at the specified index, or null if the index is out of bounds. Used by the iterator.

iterator

public Iterator iterator()

remove

public boolean remove(Object obj)

size

public int size()
Original code is Copyright (c) 1999-2001, Intalio, Inc. All Rights Reserved. Contributions by MetaBoss team are Copyright (c) 2003-2005, Softaris Pty. Ltd. All Rights Reserved.