org.qedeq.kernel.se.dto.list
Class ElementSet

java.lang.Object
  extended by org.qedeq.kernel.se.dto.list.ElementSet

public class ElementSet
extends java.lang.Object

This class represents a set of Elements.

Author:
Michael Meyling

Constructor Summary
ElementSet()
          Constructs an empty element set.
ElementSet(Element[] elements)
          Constructs an element set.
ElementSet(ElementList element)
          Constructs an element set from all operands of an element.
ElementSet(ElementSet set)
          Constructs an element set.
 
Method Summary
 ElementSet add(Element element)
          Add an element to set.
 boolean contains(Element element)
          Is element in set?
 boolean equals(java.lang.Object obj)
           
 int hashCode()
           
 ElementSet intersection(ElementSet set)
          Build the intersection.
 boolean isEmpty()
          Is this set empty?
 boolean isSubset(ElementSet set)
          Is set a superset of this set?
 java.util.Iterator iterator()
          Returns an iterator over the elements in this set.
 ElementSet minus(ElementSet set)
          Remove elements from another ElementSet from this set.
 ElementSet newDelta(ElementSet set)
          Return all elements that are only in one of both sets.
 ElementSet newIntersection(ElementSet set)
          Build a new intersection.
 ElementSet remove(Element element)
          Remove an element from this set.
 int size()
          Get number of elements.
 java.lang.String toString()
           
 ElementSet union(ElementSet set)
          Add elements from another ElementSet to this set.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ElementSet

public ElementSet()
Constructs an empty element set.


ElementSet

public ElementSet(Element[] elements)
Constructs an element set.

Parameters:
elements - the elements to put into the set
Throws:
java.lang.IllegalArgumentException - if elements was a NullPointer

ElementSet

public ElementSet(ElementSet set)
Constructs an element set.

Parameters:
set - contains the elements to put into the set
Throws:
java.lang.IllegalArgumentException - if set was a NullPointer

ElementSet

public ElementSet(ElementList element)
Constructs an element set from all operands of an element. The element must not be a symbol.

Parameters:
element - contains the elements to put into the set (without the operator)
Throws:
java.lang.IllegalArgumentException - if element was a NullPointer or was an atom.
Method Detail

contains

public final boolean contains(Element element)
Is element in set?

Parameters:
element - Element to check for.
Returns:
Is element in this set?
Throws:
java.lang.IllegalArgumentException - if the element was a NullPointer

isEmpty

public final boolean isEmpty()
Is this set empty?

Returns:
Is this set empty?

isSubset

public final boolean isSubset(ElementSet set)
Is set a superset of this set?

Parameters:
set - Set to check for.
Returns:
Is this set a subset of set?
Throws:
java.lang.IllegalArgumentException - if the set was a NullPointer

add

public final ElementSet add(Element element)
Add an element to set. This object is after the method the union of this set with {element}

Parameters:
element - element to put into the set
Returns:
Possibly changed this.
Throws:
java.lang.IllegalArgumentException - if the element was a NullPointer

union

public final ElementSet union(ElementSet set)
Add elements from another ElementSet to this set. After this method this object is the union of the two sets.

Parameters:
set - add all elements that are here
Returns:
Possibly changed this.
Throws:
java.lang.IllegalArgumentException - if the set was a NullPointer

remove

public final ElementSet remove(Element element)
Remove an element from this set.

Parameters:
element - Element to remove from the set. Must not be null.
Returns:
Possibly changed this.
Throws:
java.lang.IllegalArgumentException - if the element was a NullPointer

minus

public final ElementSet minus(ElementSet set)
Remove elements from another ElementSet from this set. After this method this object is the asymmetric set difference of the two sets: this \ set.

Parameters:
set - Remove all elements that are in this set from this.
Returns:
Possibly changed this.
Throws:
java.lang.IllegalArgumentException - if the set was a NullPointer

intersection

public final ElementSet intersection(ElementSet set)
Build the intersection.

Parameters:
set - Check for these elements.
Returns:
Possibly changed this.
Throws:
java.lang.IllegalArgumentException - if the set was a NullPointer

newIntersection

public final ElementSet newIntersection(ElementSet set)
Build a new intersection.

Parameters:
set - check for these elements
Returns:
New instance that contains all elements that were in this and set.
Throws:
java.lang.IllegalArgumentException - if the set was a NullPointer

newDelta

public final ElementSet newDelta(ElementSet set)
Return all elements that are only in one of both sets. This method returns a new instance that holds the symmetric set difference of the two sets. The original set is not modified.

Parameters:
set - Build the symmetric difference with this set. this
Returns:
Symmetric difference.
Throws:
java.lang.IllegalArgumentException - if the set was a NullPointer

size

public final int size()
Get number of elements.

Returns:
Number of elements in this set.

iterator

public java.util.Iterator iterator()
Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Returns:
Iterator over the elements in this set.

equals

public final boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

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


Copyright © 2014. All Rights Reserved.