com.ibm.tspaces.examples.mergesort
Class Merger
java.lang.Object
|
+--com.ibm.tspaces.examples.mergesort.Merger
- public class Merger
- extends java.lang.Object
- implements Eval
This class implements a runnable object that when given control in the
run method, will start merging DataTuple objects that it finds in
the space. It is designed to work with the Worker clients that are
similar in purpose to the Linda EVAL tuples.
- Author:
- John Thomas
- See Also:
MergeSort,
Tuple,
Field,
TupleSpace, Serialized Form
|
Constructor Summary |
Merger(java.lang.String name,
java.lang.String host)
Create a Merger object. |
|
Method Summary |
java.io.Serializable |
getResult()
Returns the result of the run method |
DataTuple |
mergeTuples(DataTuple t1,
DataTuple t2)
Extract the two Vectors of integers from some data Tuples and merge sort
them to produce a data Tuple with the values sorted. |
VectorWithEquals |
mergeVectors(java.util.Vector v1,
java.util.Vector v2)
Merge sort two vectors of sorted integers. |
void |
run()
The starting point of execution. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Merger
public Merger(java.lang.String name,
java.lang.String host)
- Create a Merger object.
The run method for this object will merge the mergesort data objects
that it finds in the space.
- Parameters:
host - the server where the TupleSpace residesname - the TupleSpace where the values to be sorted are stored.- See Also:
TupleSpace
run
public void run()
- The starting point of execution.
getResult
public java.io.Serializable getResult()
- Returns the result of the run method
- Specified by:
- getResult in interface Eval
- Returns:
- Either the reusult of the merge or an exception
mergeTuples
public DataTuple mergeTuples(DataTuple t1,
DataTuple t2)
throws TupleSpaceException
- Extract the two Vectors of integers from some data Tuples and merge sort
them to produce a data Tuple with the values sorted.
- Parameters:
t1 - A Tuple with the second field a Vector of sorted integers.t2 - A Tuple with the second field a Vector of sorted integers.- Returns:
- A DataTuple that contains the sorted collection of the two
vectors extracted from the parameter Tuples.
- Throws:
- TupleSpaceException - if the format of the tuple is incorrect.
mergeVectors
public VectorWithEquals mergeVectors(java.util.Vector v1,
java.util.Vector v2)
- Merge sort two vectors of sorted integers.
- Parameters:
v1 - A Vector of integers in increasing sorted order.v2 - A Vector of integers in increasing sorted order.- Returns:
- A Vector of the integers merge sorted.