org.argouml.cognitive
Class ListSet<T>

java.lang.Object
  extended by org.argouml.cognitive.ListSet<T>
Type Parameters:
T - The type of objects this ListSet is to contain.
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>, java.util.Set<T>

public class ListSet<T>
extends java.lang.Object
implements java.io.Serializable, java.util.Set<T>, java.util.List<T>

An Ordered, non-duplicated collection of objects (not exactly a mathematical set because it is ordered).

See Also:
Serialized Form

Constructor Summary
ListSet()
          The constructor.
ListSet(int n)
          The constructor.
ListSet(T o1)
          The constructor.
 
Method Summary
 void add(int arg0, T arg1)
           
 boolean add(T arg0)
           
 boolean addAll(java.util.Collection<? extends T> arg0)
           
 boolean addAll(int arg0, java.util.Collection<? extends T> arg1)
           
 void addAllElements(java.util.Collection<? extends T> v)
          Deprecated. for 0.25.4 by tfmorris. Use addAll(Collection).
 void addAllElements(java.util.Enumeration<T> iter)
           
 void addAllElements(java.util.Iterator<T> iter)
           
 void addAllElements(ListSet<T> s)
          Deprecated. for 0.25.4 by tfmorris. Use addAll(Collection).
 void addAllElementsSuchThat(java.util.Enumeration<T> iter, org.tigris.gef.util.Predicate p)
          Deprecated. for 02.6 by tfmorris. Use addAllElementsSuchThat(Iterator, org.argouml.util.Predicate) or addAllElementsSuchThat(ListSet, org.argouml.util.Predicate).
 void addAllElementsSuchThat(java.util.Iterator<T> iter, org.tigris.gef.util.Predicate p)
          Deprecated. for 0.26 by tfmorris. Use addAllElementsSuchThat(Iterator, org.argouml.util.Predicate).
 void addAllElementsSuchThat(java.util.Iterator<T> iter, org.argouml.util.Predicate p)
           
 void addAllElementsSuchThat(ListSet<T> s, org.tigris.gef.util.Predicate p)
          Deprecated. for 0.26 by tfmorris. Use addAllElementsSuchThat(ListSet, org.argouml.util.Predicate).
 void addAllElementsSuchThat(ListSet<T> s, org.argouml.util.Predicate p)
           
 void addElement(T o)
          Deprecated. for 0.25.4 by tfmorris. Use List methods instead of Vector methods.
 java.util.Vector<T> asVector()
          Deprecated. for 0.25.4 by tfmorris. Use List methods instead of Vector methods.
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection arg0)
           
 boolean containsSuchThat(org.tigris.gef.util.Predicate p)
          Deprecated. for 0.26 by tfmorris. Use containsSuchThat(org.argouml.util.Predicate).
 boolean containsSuchThat(org.argouml.util.Predicate p)
           
 T elementAt(int index)
          Deprecated. for 0.25.4 by tfmorris. Use get(int).
 java.util.Enumeration<T> elements()
          Deprecated. for 0.25.4 by tfmorris. Use iterator().
 boolean equals(java.lang.Object o)
           
 java.lang.Object findSuchThat(org.tigris.gef.util.Predicate p)
          Deprecated. for 0.26 by tfmorris. Use findSuchThat(org.argouml.util.Predicate).
 java.lang.Object findSuchThat(org.argouml.util.Predicate p)
          Return the first object that causes the given predicate to return true.
 T firstElement()
          Deprecated. for 0.25.4 by tfmorris. Use get(int) get(0).
 T get(int index)
           
 int hashCode()
           
 int indexOf(java.lang.Object o)
           
 boolean isEmpty()
           
 java.util.Iterator<T> iterator()
           
 int lastIndexOf(java.lang.Object o)
           
 java.util.ListIterator<T> listIterator()
           
 java.util.ListIterator<T> listIterator(int index)
           
 ListSet<T> reachable(org.tigris.gef.util.ChildGenerator cg)
          Deprecated. for 0.26 by tfmorris. Use reachable(org.argouml.util.ChildGenerator).
 ListSet<T> reachable(org.argouml.util.ChildGenerator cg)
          Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator.
 ListSet<T> reachable(org.tigris.gef.util.ChildGenerator cg, int max, org.tigris.gef.util.Predicate p)
          Deprecated. for 0.26 by tfmorris. Use reachable(org.argouml.util.ChildGenerator, int, org.argouml.util.Predicate).
 ListSet<T> reachable(org.argouml.util.ChildGenerator cg, int max, org.argouml.util.Predicate predicate)
          Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator.
 T remove(int index)
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection arg0)
           
 void removeAllElements()
          Remove all objects.
 void removeElement(java.lang.Object o)
           
 boolean retainAll(java.util.Collection<?> arg0)
           
 T set(int arg0, T o)
           
 int size()
           
 java.util.List<T> subList(int fromIndex, int toIndex)
           
 java.lang.Object[] toArray()
           
<A> A[]
toArray(A[] arg0)
           
 java.lang.String toString()
           
 ListSet<T> transitiveClosure(org.tigris.gef.util.ChildGenerator cg)
          Deprecated. for 0.26 by tfmorris. Use transitiveClosure(org.argouml.util.ChildGenerator).
 ListSet<T> transitiveClosure(org.argouml.util.ChildGenerator cg)
          Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator.
 ListSet<T> transitiveClosure(org.tigris.gef.util.ChildGenerator cg, int max, org.tigris.gef.util.Predicate p)
          Deprecated. for 0.26 by tfmorris. Use transitiveClosure(org.argouml.util.ChildGenerator, int, org.argouml.util.Predicate).
 ListSet<T> transitiveClosure(org.argouml.util.ChildGenerator cg, int max, org.argouml.util.Predicate predicate)
          Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListSet

public ListSet()
The constructor.


ListSet

public ListSet(int n)
The constructor.

Parameters:
n - the initial capacity of the ListSet

ListSet

public ListSet(T o1)
The constructor.

Parameters:
o1 - the first object to add
Method Detail

addElement

@Deprecated
public void addElement(T o)
Deprecated. for 0.25.4 by tfmorris. Use List methods instead of Vector methods.

Parameters:
o - the object to add

addAllElements

@Deprecated
public void addAllElements(java.util.Collection<? extends T> v)
Deprecated. for 0.25.4 by tfmorris. Use addAll(Collection).

Parameters:
v - a collection of objects to be added

addAllElements

public void addAllElements(java.util.Enumeration<T> iter)
Parameters:
iter - an enumeration of objects to be added

addAllElements

public void addAllElements(java.util.Iterator<T> iter)
Parameters:
iter - an iterator of objects to be added

addAllElementsSuchThat

@Deprecated
public void addAllElementsSuchThat(java.util.Iterator<T> iter,
                                              org.tigris.gef.util.Predicate p)
Deprecated. for 0.26 by tfmorris. Use addAllElementsSuchThat(Iterator, org.argouml.util.Predicate).

Parameters:
iter - an iterator of objects to be added
p - the predicate the objects have to fulfill to be added

addAllElementsSuchThat

public void addAllElementsSuchThat(java.util.Iterator<T> iter,
                                   org.argouml.util.Predicate p)
Parameters:
iter - an iterator of objects to be added
p - the predicate the objects have to fulfill to be added

addAllElements

@Deprecated
public void addAllElements(ListSet<T> s)
Deprecated. for 0.25.4 by tfmorris. Use addAll(Collection).

Parameters:
s - a listset of objects to be added

addAllElementsSuchThat

@Deprecated
public void addAllElementsSuchThat(ListSet<T> s,
                                              org.tigris.gef.util.Predicate p)
Deprecated. for 0.26 by tfmorris. Use addAllElementsSuchThat(ListSet, org.argouml.util.Predicate).

Parameters:
s - a listset of objects to be added
p - the predicate the objects have to fulfill to be added

addAllElementsSuchThat

public void addAllElementsSuchThat(ListSet<T> s,
                                   org.argouml.util.Predicate p)
Parameters:
s - a listset of objects to be added
p - the predicate the objects have to fulfill to be added

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<T>
Specified by:
remove in interface java.util.List<T>
Specified by:
remove in interface java.util.Set<T>

removeElement

public void removeElement(java.lang.Object o)
Parameters:
o - the object to be removed

removeAllElements

public void removeAllElements()
Remove all objects.


contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<T>
Specified by:
contains in interface java.util.List<T>
Specified by:
contains in interface java.util.Set<T>

containsSuchThat

@Deprecated
public boolean containsSuchThat(org.tigris.gef.util.Predicate p)
Deprecated. for 0.26 by tfmorris. Use containsSuchThat(org.argouml.util.Predicate).

Parameters:
p - the predicate the objects have to fulfill
Returns:
true if at least one object in the listset fulfills the predicate

containsSuchThat

public boolean containsSuchThat(org.argouml.util.Predicate p)
Parameters:
p - the predicate the objects have to fulfill
Returns:
true if at least one object in the listset fulfills the predicate

findSuchThat

@Deprecated
public java.lang.Object findSuchThat(org.tigris.gef.util.Predicate p)
Deprecated. for 0.26 by tfmorris. Use findSuchThat(org.argouml.util.Predicate).

Return the first object that causes the given predicate to return true.

Parameters:
p - the predicate the objects have to fulfill
Returns:
the found object or null

findSuchThat

public java.lang.Object findSuchThat(org.argouml.util.Predicate p)
Return the first object that causes the given predicate to return true.

Parameters:
p - the predicate the objects have to fulfill
Returns:
the found object or null

elements

@Deprecated
public java.util.Enumeration<T> elements()
Deprecated. for 0.25.4 by tfmorris. Use iterator().

Returns:
all the objects as enumeration

elementAt

@Deprecated
public T elementAt(int index)
Deprecated. for 0.25.4 by tfmorris. Use get(int).

Parameters:
index - the location
Returns:
the object at the given index

addAllElementsSuchThat

@Deprecated
public void addAllElementsSuchThat(java.util.Enumeration<T> iter,
                                              org.tigris.gef.util.Predicate p)
Deprecated. for 02.6 by tfmorris. Use addAllElementsSuchThat(Iterator, org.argouml.util.Predicate) or addAllElementsSuchThat(ListSet, org.argouml.util.Predicate).

Parameters:
iter - an enumeration of objects to be added
p - the predicate the objects have to fulfill to be added

asVector

@Deprecated
public java.util.Vector<T> asVector()
Deprecated. for 0.25.4 by tfmorris. Use List methods instead of Vector methods.

Returns:
all the objects as vector

hashCode

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

equals

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

firstElement

@Deprecated
public T firstElement()
Deprecated. for 0.25.4 by tfmorris. Use get(int) get(0).

Returns:
the first object

size

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

toString

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

transitiveClosure

@Deprecated
public ListSet<T> transitiveClosure(org.tigris.gef.util.ChildGenerator cg)
Deprecated. for 0.26 by tfmorris. Use transitiveClosure(org.argouml.util.ChildGenerator).

Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator. The result includes the elements of the original Set. In order to avoid very deep searches which are often programming mistakes, only paths of length TC_LIMIT or less are considered.

Parameters:
cg - the given childgenerator
Returns:
the resulting listset

transitiveClosure

public ListSet<T> transitiveClosure(org.argouml.util.ChildGenerator cg)
Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator. The result includes the elements of the original Set. In order to avoid very deep searches which are often programming mistakes, only paths of length TC_LIMIT or less are considered.

Parameters:
cg - the given childgenerator
Returns:
the resulting listset

reachable

@Deprecated
public ListSet<T> reachable(org.tigris.gef.util.ChildGenerator cg)
Deprecated. for 0.26 by tfmorris. Use reachable(org.argouml.util.ChildGenerator).

Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator. The result DOES NOT include the elements of the original Set. In order to avoid very deep searches which are often programming mistakes, only paths of length TC_LIMIT or less are considered.

Parameters:
cg - the given childgenerator
Returns:
the resulting listset

reachable

public ListSet<T> reachable(org.argouml.util.ChildGenerator cg)
Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator. The result DOES NOT include the elements of the original Set. In order to avoid very deep searches which are often programming mistakes, only paths of length TC_LIMIT or less are considered.

Parameters:
cg - the given childgenerator
Returns:
the resulting listset

reachable

@Deprecated
public ListSet<T> reachable(org.tigris.gef.util.ChildGenerator cg,
                                       int max,
                                       org.tigris.gef.util.Predicate p)
Deprecated. for 0.26 by tfmorris. Use reachable(org.argouml.util.ChildGenerator, int, org.argouml.util.Predicate).

Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator. The result DOES NOT include the elements of the original Set. In order to avoid very deep searches which are often programming mistakes, only paths of given max length or less are considered. Only paths consisting of elements which all cause p.predicate() to return true are considered.

Parameters:
cg - the given childgenerator
max - the maximum depth
p - the predicate the objects have to fulfill
Returns:
the resulting listset

reachable

public ListSet<T> reachable(org.argouml.util.ChildGenerator cg,
                            int max,
                            org.argouml.util.Predicate predicate)
Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator. The result DOES NOT include the elements of the original Set. In order to avoid very deep searches which are often programming mistakes, only paths of given max length or less are considered. Only paths consisting of elements which all cause predicate.evaluate() to return true are considered.

Parameters:
cg - the given childgenerator
max - the maximum depth
predicate - the predicate the objects have to fulfill
Returns:
the resulting listset

transitiveClosure

@Deprecated
public ListSet<T> transitiveClosure(org.tigris.gef.util.ChildGenerator cg,
                                               int max,
                                               org.tigris.gef.util.Predicate p)
Deprecated. for 0.26 by tfmorris. Use transitiveClosure(org.argouml.util.ChildGenerator, int, org.argouml.util.Predicate).

Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator. The result includes the elements of the original Set. In order to avoid very deep searches which are often programming mistakes, only paths of given max length or less are considered. Only paths consisting of elements which all cause p.predicate() to return true are considered.

Parameters:
cg - the given childgenerator
max - the maximum depth
p - the predicate the objects have to fulfill
Returns:
the resulting listset

transitiveClosure

public ListSet<T> transitiveClosure(org.argouml.util.ChildGenerator cg,
                                    int max,
                                    org.argouml.util.Predicate predicate)
Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator. The result includes the elements of the original Set. In order to avoid very deep searches which are often programming mistakes, only paths of given max length or less are considered. Only paths consisting of elements which all cause predicate.evaluate() to return true are considered.

Parameters:
cg - the given childgenerator
max - the maximum depth
predicate - the predicate the objects have to fulfill
Returns:
the resulting listset

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<T>
Specified by:
isEmpty in interface java.util.List<T>
Specified by:
isEmpty in interface java.util.Set<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.List<T>
Specified by:
iterator in interface java.util.Set<T>

toArray

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

toArray

public <A> A[] toArray(A[] arg0)
Specified by:
toArray in interface java.util.Collection<T>
Specified by:
toArray in interface java.util.List<T>
Specified by:
toArray in interface java.util.Set<T>

add

public boolean add(T arg0)
Specified by:
add in interface java.util.Collection<T>
Specified by:
add in interface java.util.List<T>
Specified by:
add in interface java.util.Set<T>

containsAll

public boolean containsAll(java.util.Collection arg0)
Specified by:
containsAll in interface java.util.Collection<T>
Specified by:
containsAll in interface java.util.List<T>
Specified by:
containsAll in interface java.util.Set<T>

addAll

public boolean addAll(java.util.Collection<? extends T> arg0)
Specified by:
addAll in interface java.util.Collection<T>
Specified by:
addAll in interface java.util.List<T>
Specified by:
addAll in interface java.util.Set<T>

retainAll

public boolean retainAll(java.util.Collection<?> arg0)
Specified by:
retainAll in interface java.util.Collection<T>
Specified by:
retainAll in interface java.util.List<T>
Specified by:
retainAll in interface java.util.Set<T>

removeAll

public boolean removeAll(java.util.Collection arg0)
Specified by:
removeAll in interface java.util.Collection<T>
Specified by:
removeAll in interface java.util.List<T>
Specified by:
removeAll in interface java.util.Set<T>

clear

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

addAll

public boolean addAll(int arg0,
                      java.util.Collection<? extends T> arg1)
Specified by:
addAll in interface java.util.List<T>

get

public T get(int index)
Specified by:
get in interface java.util.List<T>

set

public T set(int arg0,
             T o)
Specified by:
set in interface java.util.List<T>

add

public void add(int arg0,
                T arg1)
Specified by:
add in interface java.util.List<T>

remove

public T remove(int index)
Specified by:
remove in interface java.util.List<T>

indexOf

public int indexOf(java.lang.Object o)
Specified by:
indexOf in interface java.util.List<T>

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Specified by:
lastIndexOf in interface java.util.List<T>

listIterator

public java.util.ListIterator<T> listIterator()
Specified by:
listIterator in interface java.util.List<T>

listIterator

public java.util.ListIterator<T> listIterator(int index)
Specified by:
listIterator in interface java.util.List<T>

subList

public java.util.List<T> subList(int fromIndex,
                                 int toIndex)
Specified by:
subList in interface java.util.List<T>


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Cookbook