Opus5
Class MultisetAsLinkedList
java.lang.Object
|
+--Opus5.AbstractObject
|
+--Opus5.AbstractContainer
|
+--Opus5.AbstractSearchableContainer
|
+--Opus5.AbstractSet
|
+--Opus5.MultisetAsLinkedList
- All Implemented Interfaces:
- Comparable, Container, Multiset, SearchableContainer
- public class MultisetAsLinkedList
- extends AbstractSet
- implements Multiset
Multiset implemented using a linked list.
- Version:
- $Id: MultisetAsLinkedList.java,v 3.5 1998/07/28 12:02:38 brpreiss Exp $
- Author:
- Bruno R. Preiss, P.Eng.
|
Constructor Summary |
MultisetAsLinkedList(int n)
Constructs a MultisetAsLinkedList for the specified size
of universal multiset. |
|
Method Summary |
void |
accept(Visitor visitor)
Accepts a visitor and makes it visit the elements of this multiset. |
protected int |
compareTo(Comparable arg)
Compares this multiset with the specified comparable object. |
Multiset |
difference(Multiset set)
Returns a multiset which is the difference between this multiset
and the specified multiset. |
int |
getCount()
Returns the number of elements in this multiset. |
Enumeration |
getEnumeration()
Returns an enumeration that enumerates the elements of this multiset. |
protected void |
insert(int item)
Inserts the specified item into this multiset. |
Multiset |
intersection(Multiset set)
Returns a multiset which is the intersection of this multiset
and the specified multiset. |
boolean |
isEQ(Multiset set)
Tests whether this multiset is equal to the specified multiset. |
protected boolean |
isMember(int item)
Tests if the specified item is a member of this multiset. |
boolean |
isSubset(Multiset set)
Tests whether this multiset is a subset of the specified multiset. |
void |
purge()
Purges this multiset, making it empty. |
Multiset |
union(Multiset set)
Returns a multiset which is the union of this multiset
and the specified multiset. |
protected void |
withdraw(int item)
Withdraws the specified item from this multiset. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
list
protected LinkedList list
- The linked list.
MultisetAsLinkedList
public MultisetAsLinkedList(int n)
- Constructs a
MultisetAsLinkedList for the specified size
of universal multiset.
- Parameters:
n - The number of elements in the universal multiset.
insert
protected void insert(int item)
- Inserts the specified item into this multiset.
- Overrides:
insert in class AbstractSet
- Parameters:
item - The item to insert.
withdraw
protected void withdraw(int item)
- Withdraws the specified item from this multiset.
- Overrides:
withdraw in class AbstractSet
- Parameters:
item - The item to be withdrawn.
isMember
protected boolean isMember(int item)
- Tests if the specified item is a member of this multiset.
- Overrides:
isMember in class AbstractSet
- Parameters:
item - The item for which to look.- Returns:
- True if the item is a member of this multiset; false otherwise.
purge
public void purge()
- Purges this multiset, making it empty.
- Specified by:
purge in interface Container
getCount
public int getCount()
- Returns the number of elements in this multiset.
- Specified by:
getCount in interface Container- Overrides:
getCount in class AbstractContainer
- Returns:
- The number of elements in this multiset.
accept
public void accept(Visitor visitor)
- Accepts a visitor and makes it visit the elements of this multiset.
- Specified by:
accept in interface Container- Overrides:
accept in class AbstractContainer
- Parameters:
visitor - The visitor to accept.
union
public Multiset union(Multiset set)
- Returns a multiset which is the union of this multiset
and the specified multiset.
It is assumed that the specified multiset is an instance of
the
MultisetAsLinkedList class.
- Specified by:
union in interface Multiset
- Parameters:
multiset - The multiset to join with this multiset.- Returns:
- The union of this multiset with the specified multiset.
- Throws:
java.lang.IllegalArgumentException - If the sizes of the universal multisets differ.
intersection
public Multiset intersection(Multiset set)
- Returns a multiset which is the intersection of this multiset
and the specified multiset.
It is assumed that the specified multiset is an instance of
the
MultisetAsLinkedList class.
- Specified by:
intersection in interface Multiset
- Parameters:
multiset - The multiset to intersect with this multiset.- Returns:
- The intersection of this multiset with the specified multiset.
- Throws:
java.lang.IllegalArgumentException - If the sizes of the universal multisets differ.
difference
public Multiset difference(Multiset set)
- Returns a multiset which is the difference between this multiset
and the specified multiset.
It is assumed that the specified multiset is an instance of
the
MultisetAsLinkedList class.
- Specified by:
difference in interface Multiset
- Parameters:
multiset - The multiset to subtract from this multiset.- Returns:
- The difference between this multiset and the specified multiset.
- Throws:
java.lang.IllegalArgumentException - If the sizes of the universal multisets differ.
isSubset
public boolean isSubset(Multiset set)
- Tests whether this multiset is a subset of the specified multiset.
It is assumed that the specified multiset is an instance of
the
MultisetAsLinkedList class.
- Specified by:
isSubset in interface Multiset
- Parameters:
multiset - The multiset to compare with this multiset.- Returns:
- True if the this multiset is a subset of the specified multiset;
false otherwise.
- Throws:
java.lang.IllegalArgumentException - If the sizes of the universal multisets differ.
isEQ
public boolean isEQ(Multiset set)
- Tests whether this multiset is equal to the specified multiset.
It is assumed that the specified multiset is an instance of
the
MultisetAsLinkedList class.
- Specified by:
isEQ in interface Multiset
- Parameters:
multiset - The multiset to compare with this multiset.- Returns:
- True if the multisets are equal; false otherwise.
- Throws:
java.lang.IllegalArgumentException - If the sizes of the universal multisets differ.
getEnumeration
public Enumeration getEnumeration()
- Returns an enumeration that enumerates the elements of this multiset.
- Specified by:
getEnumeration in interface Container
- Returns:
- An enumeration that enumerates the elements of this multiset.
compareTo
protected int compareTo(Comparable arg)
- Compares this multiset with the specified comparable object.
This method is not implemented.
- Overrides:
compareTo in class AbstractObject
- Parameters:
arg - The comparable object to compare with this multiset.- Throws:
MethodNotImplemented - Alwys.