mauda.operation
Class OperationQueue

java.lang.Object
  extended by mauda.operation.OperationQueue
All Implemented Interfaces:
java.lang.Comparable

public class OperationQueue
extends java.lang.Object
implements java.lang.Comparable

Storage of a collection of multiple base-operations. Additionally this class has several needed methods to manipulate or generate new OperationQueue's. For Example:
- shuffle
- get all permutations of the operations the queue holds
- execution of the whole cue
- load
- save

Author:
Markus Krebs

Constructor Summary
OperationQueue()
          Creates a OperationQueue
 
Method Summary
 void add(Operation operation)
          Adds a Operation
 void add(java.lang.String id)
          Adds a Operation via ID
 void addAll(OperationQueue o)
          Adds all Operations of the delivered OperationQueue to this OperationQueue
 java.lang.Object clone()
           
 int compareTo(java.lang.Object o)
           
 void execute(java.lang.Object o)
          Executes all Operations in this queue on the data-structure, by calling the execute-Method of all its Operation's
 Operation get(int index)
          Gets the index'th Operation of this queue
 OperationQueue[] getPermutations()
          Gets all permutations of this OperationQueue
 int getRating()
          Returns the accumulated rating of all Operations
 int length()
          Gets the length
 void load(java.util.Vector vector)
          Loads this OperationQueue with the values from a vector- representation readed from e.g. a xml-file.
 void remove(int index)
          Removes a operation at a specified index
 java.util.Vector save()
          Converts this queue in a vector-representation for saving- purposes.
 void set(int index, Operation op)
          Sets a operation at the specified index
 void setRating(int rating)
          Sets the rating
 void shuffle()
          Shuffles the operations in this queue
 void shuffleDelmin()
          Shuffles the operations so that DELETE_MIN lies inside the last 4 operations.
 Operation[] toArray()
          Converts this OperationQueue to an array
 java.lang.String toString()
           
 java.util.Vector toVector()
          Converts this OperationQueue to an vector
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OperationQueue

public OperationQueue()
Creates a OperationQueue

Method Detail

add

public void add(java.lang.String id)
Adds a Operation via ID

Parameters:
id - operation-ID

add

public void add(Operation operation)
Adds a Operation

Parameters:
operation - Operation

addAll

public void addAll(OperationQueue o)
Adds all Operations of the delivered OperationQueue to this OperationQueue

Parameters:
o - OperationQueue

get

public Operation get(int index)
Gets the index'th Operation of this queue

Parameters:
index - Index
Returns:
Operation

set

public void set(int index,
                Operation op)
Sets a operation at the specified index

Parameters:
index - Index to store the delivered Operation
op - The new Operation for the position at Index

remove

public void remove(int index)
Removes a operation at a specified index

Parameters:
index - Index of the to removed operation

shuffle

public void shuffle()
Shuffles the operations in this queue


shuffleDelmin

public void shuffleDelmin()
Shuffles the operations so that DELETE_MIN lies inside the last 4 operations.


getPermutations

public OperationQueue[] getPermutations()
Gets all permutations of this OperationQueue

Returns:
permutations as OperationQueue's

toArray

public Operation[] toArray()
Converts this OperationQueue to an array

Returns:
array of Operation's

toVector

public java.util.Vector toVector()
Converts this OperationQueue to an vector

Returns:
vector of Operation's

length

public int length()
Gets the length

Returns:
length

getRating

public int getRating()
Returns the accumulated rating of all Operations

Returns:
rating

setRating

public void setRating(int rating)
Sets the rating

Parameters:
rating - Rating

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

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

execute

public void execute(java.lang.Object o)
Executes all Operations in this queue on the data-structure, by calling the execute-Method of all its Operation's

Parameters:
o - data-structure-object
See Also:
SimpleOperation.execute(Object)

save

public java.util.Vector save()
Converts this queue in a vector-representation for saving- purposes.

Returns:
vector-representation of this queue

load

public void load(java.util.Vector vector)
Loads this OperationQueue with the values from a vector- representation readed from e.g. a xml-file.

Parameters:
vector - vector-representation