org.databene.commons
Class OrderedSet<E>

java.lang.Object
  extended by org.databene.commons.OrderedSet<E>
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

public class OrderedSet<E>
extends java.lang.Object
implements java.util.Set<E>

Set implementation that tracks the order in which elements where added and returns them in that order by the iterator() method.

This is useful for all cases in which elements need to be unique but processed in the original order.

* Created at 28.02.2009 12:26:35

Since:
0.4.8
Author:
Volker Bergmann

Constructor Summary
OrderedSet()
           
OrderedSet(java.util.Collection<E> source)
           
OrderedSet(int initialCapacity)
           
OrderedSet(int initialCapacity, float loadFactor)
           
 
Method Summary
 boolean add(E item)
           
 boolean addAll(java.util.Collection<? extends E> source)
           
 void clear()
           
 boolean contains(java.lang.Object item)
           
 boolean containsAll(java.util.Collection<?> items)
           
 boolean equals(java.lang.Object obj)
           
 E get(int index)
           
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Iterator<E> iterator()
           
 boolean remove(java.lang.Object item)
           
 boolean removeAll(java.util.Collection<?> items)
           
 boolean retainAll(java.util.Collection<?> items)
           
 int size()
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] array)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrderedSet

public OrderedSet()

OrderedSet

public OrderedSet(int initialCapacity)

OrderedSet

public OrderedSet(int initialCapacity,
                  float loadFactor)

OrderedSet

public OrderedSet(java.util.Collection<E> source)
Method Detail

add

public boolean add(E item)
Specified by:
add in interface java.util.Collection<E>
Specified by:
add in interface java.util.Set<E>

addAll

public boolean addAll(java.util.Collection<? extends E> source)
Specified by:
addAll in interface java.util.Collection<E>
Specified by:
addAll in interface java.util.Set<E>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<E>
Specified by:
clear in interface java.util.Set<E>

contains

public boolean contains(java.lang.Object item)
Specified by:
contains in interface java.util.Collection<E>
Specified by:
contains in interface java.util.Set<E>

containsAll

public boolean containsAll(java.util.Collection<?> items)
Specified by:
containsAll in interface java.util.Collection<E>
Specified by:
containsAll in interface java.util.Set<E>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<E>
Specified by:
isEmpty in interface java.util.Set<E>

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Specified by:
iterator in interface java.util.Set<E>

remove

public boolean remove(java.lang.Object item)
Specified by:
remove in interface java.util.Collection<E>
Specified by:
remove in interface java.util.Set<E>

removeAll

public boolean removeAll(java.util.Collection<?> items)
Specified by:
removeAll in interface java.util.Collection<E>
Specified by:
removeAll in interface java.util.Set<E>

retainAll

public boolean retainAll(java.util.Collection<?> items)
Specified by:
retainAll in interface java.util.Collection<E>
Specified by:
retainAll in interface java.util.Set<E>

size

public int size()
Specified by:
size in interface java.util.Collection<E>
Specified by:
size in interface java.util.Set<E>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<E>
Specified by:
toArray in interface java.util.Set<E>

toArray

public <T> T[] toArray(T[] array)
Specified by:
toArray in interface java.util.Collection<E>
Specified by:
toArray in interface java.util.Set<E>

get

public E get(int index)

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection<E>
Specified by:
hashCode in interface java.util.Set<E>
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Collection<E>
Specified by:
equals in interface java.util.Set<E>
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2010. All Rights Reserved.