org.argouml.cognitive
Class ListSet

java.lang.Object
  extended byorg.argouml.cognitive.ListSet
All Implemented Interfaces:
Collection, List, Serializable, Set

public class ListSet
extends Object
implements Serializable, Set, List

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

See Also:
Serialized Form

Constructor Summary
ListSet()
          The constructor.
ListSet(int n)
          The constructor.
ListSet(Object o1)
          The constructor.
 
Method Summary
 void add(int arg0, Object arg1)
           
 boolean add(Object arg0)
           
 boolean addAll(Collection arg0)
           
 boolean addAll(int arg0, Collection arg1)
           
 void addAllElements(Collection v)
           
 void addAllElements(Enumeration iter)
           
 void addAllElements(Iterator iter)
           
 void addAllElements(ListSet s)
           
 void addAllElementsSuchThat(Enumeration iter, Predicate p)
           
 void addAllElementsSuchThat(Iterator iter, Predicate p)
           
 void addAllElementsSuchThat(ListSet s, Predicate p)
           
 void addElement(Object o)
           
 Vector asVector()
           
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection arg0)
           
 boolean containsSuchThat(Predicate p)
           
 Object elementAt(int index)
           
 Enumeration elements()
           
 boolean equals(Object o)
           
 Object findSuchThat(Predicate p)
          Return the first object that causes the given predicate to return true.
 Object firstElement()
           
 Object get(int index)
           
 int hashCode()
           
 int indexOf(Object o)
           
 boolean isEmpty()
           
 Iterator iterator()
           
 int lastIndexOf(Object o)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
 ListSet reachable(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 reachable(ChildGenerator cg, int max, Predicate p)
          Reply the Set of all objects that can be reached from the receiving Set by taking steps defined by the given ChildGenerator.
 Object remove(int index)
           
 boolean remove(Object o)
           
 boolean removeAll(Collection arg0)
           
 void removeAllElements()
          Remove all objects.
 void removeElement(Object o)
           
 boolean retainAll(Collection arg0)
           
 Object set(int arg0, Object o)
           
 int size()
           
 List subList(int fromIndex, int toIndex)
           
 Object[] toArray()
           
 Object[] toArray(Object[] arg0)
           
 String toString()
           
 ListSet transitiveClosure(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 transitiveClosure(ChildGenerator cg, int max, Predicate p)
          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 vector

ListSet

public ListSet(Object o1)
The constructor.

Parameters:
o1 - the first object to add
Method Detail

addElement

public void addElement(Object o)
Parameters:
o - the object to add

addAllElements

public void addAllElements(Collection v)
Parameters:
v - a collection of objects to be added

addAllElements

public void addAllElements(Enumeration iter)
Parameters:
iter - an enumeration of objects to be added

addAllElements

public void addAllElements(Iterator iter)
Parameters:
iter - an iterator of objects to be added

addAllElementsSuchThat

public void addAllElementsSuchThat(Enumeration iter,
                                   Predicate p)
Parameters:
iter - an enumeration of objects to be added
p - the predicate the objects have to fulfill to be added

addAllElementsSuchThat

public void addAllElementsSuchThat(Iterator iter,
                                   Predicate p)
Parameters:
iter - an iterator of objects to be added
p - the predicate the objects have to fulfill to be added

addAllElements

public void addAllElements(ListSet s)
Parameters:
s - a listset of objects to be added

addAllElementsSuchThat

public void addAllElementsSuchThat(ListSet s,
                                   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(Object o)
Specified by:
remove in interface Set
See Also:
Collection.remove(java.lang.Object)

removeElement

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

removeAllElements

public void removeAllElements()
Remove all objects.


contains

public boolean contains(Object o)
Specified by:
contains in interface Set
See Also:
Collection.contains(java.lang.Object)

containsSuchThat

public boolean containsSuchThat(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

public Object findSuchThat(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

public Enumeration elements()
Returns:
all the objects as enumeration

elementAt

public Object elementAt(int index)
Parameters:
index - the location
Returns:
the object at the given index

asVector

public Vector asVector()
Returns:
all the objects as vector

hashCode

public int hashCode()
Specified by:
hashCode in interface Set
See Also:
This will result in rather bad performance but at least we will not violate the contract together with {@link #equals(Object)}.

equals

public boolean equals(Object o)
Specified by:
equals in interface Set
See Also:
Object.equals(java.lang.Object)

firstElement

public Object firstElement()
Returns:
the first object

size

public int size()
Specified by:
size in interface Set
See Also:
Collection.size()

toString

public String toString()
See Also:
Object.toString()

transitiveClosure

public ListSet transitiveClosure(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

public ListSet reachable(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

public ListSet reachable(ChildGenerator cg,
                         int max,
                         Predicate p)
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

transitiveClosure

public ListSet transitiveClosure(ChildGenerator cg,
                                 int max,
                                 Predicate p)
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

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Set
See Also:
Collection.isEmpty()

iterator

public Iterator iterator()
Specified by:
iterator in interface Set
See Also:
Collection.iterator()

toArray

public Object[] toArray()
Specified by:
toArray in interface Set
See Also:
Collection.toArray()

toArray

public Object[] toArray(Object[] arg0)
Specified by:
toArray in interface Set
See Also:
Collection.toArray(java.lang.Object[])

add

public boolean add(Object arg0)
Specified by:
add in interface Set
See Also:
Collection.add(java.lang.Object)

containsAll

public boolean containsAll(Collection arg0)
Specified by:
containsAll in interface Set
See Also:
Collection.containsAll(java.util.Collection)

addAll

public boolean addAll(Collection arg0)
Specified by:
addAll in interface Set
See Also:
Collection.addAll(java.util.Collection)

retainAll

public boolean retainAll(Collection arg0)
Specified by:
retainAll in interface Set
See Also:
Collection.retainAll(java.util.Collection)

removeAll

public boolean removeAll(Collection arg0)
Specified by:
removeAll in interface Set
See Also:
Collection.removeAll(java.util.Collection)

clear

public void clear()
Specified by:
clear in interface Set
See Also:
Collection.clear()

addAll

public boolean addAll(int arg0,
                      Collection arg1)
Specified by:
addAll in interface List
See Also:
List.addAll(int, java.util.Collection)

get

public Object get(int index)
Specified by:
get in interface List
See Also:
List.get(int)

set

public Object set(int arg0,
                  Object o)
Specified by:
set in interface List
See Also:
List.set(int, java.lang.Object)

add

public void add(int arg0,
                Object arg1)
Specified by:
add in interface List
See Also:
List.add(int, java.lang.Object)

remove

public Object remove(int index)
Specified by:
remove in interface List
See Also:
List.remove(int)

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List
See Also:
List.indexOf(java.lang.Object)

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List
See Also:
List.lastIndexOf(java.lang.Object)

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List
See Also:
List.listIterator()

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List
See Also:
List.listIterator(int)

subList

public List subList(int fromIndex,
                    int toIndex)
Specified by:
subList in interface List
See Also:
List.subList(int, int)


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Cookbook