org.jtool.jxplatform.graph
Class GraphElementSet

java.lang.Object
  extended byorg.jtool.jxplatform.graph.GraphElementSet

public class GraphElementSet
extends java.lang.Object

A set of GraphElement. The implementation uses the java.util.LinkedHashSet class to maintain the insertion-order.

Author:
Katsuhsa Maruyama

Constructor Summary
GraphElementSet()
          Creates a new, empty set.
GraphElementSet(GraphElementList list)
          Creates a new set from a list of graph elements.
GraphElementSet(GraphElementSet set)
          Creates a new set from a set of GraphElement elements.
 
Method Summary
 boolean add(GraphElement elem)
          Appends a graph element to this list.
 void clear()
          Removes all graph elements from this set.
 boolean contains(GraphElement elem)
          Tests if this set contains a graph element.
 GraphElementSet difference(GraphElementSet set)
          Obtains a difference set of this set and a given set.
 boolean equals(GraphElementSet set)
          Tests if this set is equals to a given set.
 GraphElement getGraphElement()
          Returns one graph element in this set.
 GraphElementSet intersection(GraphElementSet set)
          Obtains an intersection set of this set and a given set.
 boolean isEmpty()
          Tests if this set contains no graph element.
 java.util.Iterator iterator()
          Returns an iterator of this set in proper sequence.
 void print()
          Displays information about this set.
 boolean remove(GraphElement elem)
          Removes a graph element from this set.
 int size()
          Returns the number of graph elements in this set.
 boolean subset(GraphElementSet set)
          Tests if this set is a subset of a given set.
 boolean subsetEqual(GraphElementSet set)
          Tests if this set is a subset of a given set or this set equals to the given set.
 GraphElement[] toArray()
          Returns an array containing all graph elements in this set in proper sequence.
 GraphElementSet union(GraphElementSet set)
          Obtains a union set of this set and a given set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphElementSet

public GraphElementSet()
Creates a new, empty set.


GraphElementSet

public GraphElementSet(GraphElementSet set)
Creates a new set from a set of GraphElement elements.

Parameters:
set - A set of graph elements.

GraphElementSet

public GraphElementSet(GraphElementList list)
Creates a new set from a list of graph elements. One of duplicated graph elements remains in the cretaed set.

Parameters:
list - A list of graph elements.
Method Detail

clear

public void clear()
Removes all graph elements from this set.


add

public boolean add(GraphElement elem)
Appends a graph element to this list.

Parameters:
elem - A graph element to be appended.
Returns:
true if this set changed as a result of the call.

remove

public boolean remove(GraphElement elem)
Removes a graph element from this set.

Parameters:
elem - A graph element to be removed.
Returns:
true if this lispreservet changed as a result of the call.

contains

public boolean contains(GraphElement elem)
Tests if this set contains a graph element.

Parameters:
elem - A graph element to be tested.
Returns:
true if the graph element is present, otherwise false.

isEmpty

public boolean isEmpty()
Tests if this set contains no graph element.

Returns:
true if this set contains no graph element, otherwise false.

size

public int size()
Returns the number of graph elements in this set.

Returns:
The number of graph elements.

getGraphElement

public GraphElement getGraphElement()
Returns one graph element in this set. Truly, the first element will be returned.

Returns:
The graph element, or null if there is no graph element in this set.

iterator

public java.util.Iterator iterator()
Returns an iterator of this set in proper sequence.

Returns:
An iterator of this set.

equals

public boolean equals(GraphElementSet set)
Tests if this set is equals to a given set.

Parameters:
set - A set to be tested.
Returns:
true if both the sets are equal, otherwise false.

union

public GraphElementSet union(GraphElementSet set)
Obtains a union set of this set and a given set.

Parameters:
set - A set of graph elements.
Returns:
A union set.

intersection

public GraphElementSet intersection(GraphElementSet set)
Obtains an intersection set of this set and a given set.

Parameters:
set - A set of graph elements.
Returns:
An intersection set.

difference

public GraphElementSet difference(GraphElementSet set)
Obtains a difference set of this set and a given set.

Parameters:
set - A set of graph elements.
Returns:
A difference set which leaves behind elements of this set after removing elements of the given set.

subset

public boolean subset(GraphElementSet set)
Tests if this set is a subset of a given set.

Parameters:
set - A set of graph elements.
Returns:
true if this set is a subset of the given set, otherwise false.

subsetEqual

public boolean subsetEqual(GraphElementSet set)
Tests if this set is a subset of a given set or this set equals to the given set.

Parameters:
set - A set of graph elements.
Returns:
true if this set is a subset of the given set or this set equals to the given set, otherwise false.

toArray

public GraphElement[] toArray()
Returns an array containing all graph elements in this set in proper sequence.

Returns:
An array of graph elements.

print

public void print()
Displays information about this set.