jltools.util
Class SubtypeSet
java.lang.Object
|
+--jltools.util.SubtypeSet
- All Implemented Interfaces:
- java.util.Collection, java.util.Set
- public class SubtypeSet
- extends java.lang.Object
- implements java.util.Set
Class to implement sets containing jltools.types.Type .
Set membership is based on the subtype relationships. Thus, if
S is a supertype of A and B, then
{ S } union { A,B } =
{ S }. Similarily, we remove elements from the set such
that if s is an element of a set S, then a
call to remove r removes all s iff r is a
a supertype of s.
|
Constructor Summary |
SubtypeSet()
Creates an empty SubtypeSet |
|
Method Summary |
boolean |
add(java.lang.Object o)
Add an element of type jltools.types.Type to the set
only if it has no supertypes already in the set. |
boolean |
addAll(java.util.Collection c)
Adds all elements from c into this set. |
void |
clear()
Removes all elements from the set |
boolean |
contains(java.lang.Object o)
Check whether object o is in the set. |
boolean |
containsAll(java.util.Collection c)
Checks whether all elements of the collection are in the set |
boolean |
isEmpty()
|
java.util.Iterator |
iterator()
|
boolean |
remove(java.lang.Object o)
Removes all elements s in the set such that
s decends from o |
boolean |
removeAll(java.util.Collection c)
|
boolean |
retainAll(java.util.Collection c)
|
int |
size()
|
java.lang.Object[] |
toArray()
|
java.lang.Object[] |
toArray(java.lang.Object[] a)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
equals, hashCode |
SubtypeSet
public SubtypeSet()
- Creates an empty SubtypeSet
add
public boolean add(java.lang.Object o)
- Add an element of type
jltools.types.Type to the set
only if it has no supertypes already in the set. If we do add it,
remove any subtypes of o
- Specified by:
add in interface java.util.Set
- Parameters:
o - The element to add.
addAll
public boolean addAll(java.util.Collection c)
- Adds all elements from c into this set.
- Specified by:
addAll in interface java.util.Set
clear
public void clear()
- Removes all elements from the set
- Specified by:
clear in interface java.util.Set
contains
public boolean contains(java.lang.Object o)
- Check whether object
o is in the set. Because of the
semantics of the subtype set, o is in the set iff
it descends from (or is equal to) one of the elements in the set.
- Specified by:
contains in interface java.util.Set
containsAll
public boolean containsAll(java.util.Collection c)
- Checks whether all elements of the collection are in the set
- Specified by:
containsAll in interface java.util.Set
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface java.util.Set
iterator
public java.util.Iterator iterator()
- Specified by:
iterator in interface java.util.Set
remove
public boolean remove(java.lang.Object o)
- Removes all elements
s in the set such that
s decends from o
- Specified by:
remove in interface java.util.Set
- Returns:
- whether or not an element was removed.
removeAll
public boolean removeAll(java.util.Collection c)
- Specified by:
removeAll in interface java.util.Set
retainAll
public boolean retainAll(java.util.Collection c)
- Specified by:
retainAll in interface java.util.Set
size
public int size()
- Specified by:
size in interface java.util.Set
toArray
public java.lang.Object[] toArray()
- Specified by:
toArray in interface java.util.Set
toArray
public java.lang.Object[] toArray(java.lang.Object[] a)
- Specified by:
toArray in interface java.util.Set
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object