net.israfil.foundation.collections
Class ArraySet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by net.israfil.foundation.collections.ArraySet
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection, java.util.Set

public class ArraySet
extends java.util.AbstractSet

An ArrayList backed Set implementation, whose primary purpose is to provide a Set that maintains the order of elements based on indexes and/or the order in which items are added. Most particularly it's to guarrantee deterministic results of an iterator, where the iterator provides each element in the order of the underlying list. Note that the current implementation is limited, insofar as you cannot get arraylist-like behaviour from it such as inserting. You can add, and it's a bit like a stack-set, actually. TODO: Consider making this a SortedSet, using the list order as the guarrantee. Not sure if it's a legit use of the API.

Author:
Christian Edward Gruber

Constructor Summary
ArraySet()
           
ArraySet(java.util.Collection col)
           
ArraySet(int initialCapacity)
           
 
Method Summary
 boolean add(java.lang.Object o)
           
 java.util.Iterator iterator()
           
 boolean remove(java.lang.Object o)
           
 int size()
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, 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
addAll, clear, contains, containsAll, isEmpty, retainAll, toArray, toArray
 

Constructor Detail

ArraySet

public ArraySet()

ArraySet

public ArraySet(int initialCapacity)

ArraySet

public ArraySet(java.util.Collection col)
Method Detail

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.Set
Specified by:
iterator in class java.util.AbstractCollection

size

public int size()
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.Set
Specified by:
size in class java.util.AbstractCollection

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.Set
Overrides:
add in class java.util.AbstractCollection

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.Set
Overrides:
remove in class java.util.AbstractCollection


Copyright © 2003-2006. All Rights Reserved.