ikg.eleven.sortarray
Class SortArray

java.lang.Object
  extended by ikg.eleven.sortarray.SortArray

public class SortArray
extends java.lang.Object

This class gives an array of integers for testing sorting algorithms.


Constructor Summary
SortArray(int number)
          Constructor with the maximum number of elemnts.
 
Method Summary
 boolean equal(int posOne, int posTwo)
          Two elements are compared.
 void fillInvers()
          Invers filling with values from maximum to zero.
 void fillNormal()
          Ordered filling with values from zero to maximum -1.
 void fillRandom()
          The array is filled with random numbers between 1 and the maximum
given by the constructor.
 java.lang.String getElapsedTime()
          The actual elapsed time is returned as String
 int getStart()
          The lowest array index is returned.
 int getStop()
          The highest array index is returned.
 boolean greater(int posOne, int posTwo)
          Two elements are compared.
 boolean isEqual(int pos, int value)
          One element of the array at position pos and the number value are compared.
 boolean isGreater(int pos, int value)
          One element of the array at position pos and the number value are compared.
 boolean isLess(int pos, int value)
          One element of the array at position pos and the number value are compared.
 boolean less(int posOne, int posTwo)
          Two elements are compared.
 void replace(int from, int to)
          Two array elements change their places.
 void setObserver(char oType)
          Determine which type of Observer is used
 void showTime()
          The difference between the two saved timestamps is written to the terminal.
 void startClock()
          The actual time is determined and saved.
 void stopClock()
          The actual time is determined and saved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortArray

public SortArray(int number)
Constructor with the maximum number of elemnts.
This number is checked.

Method Detail

setObserver

public void setObserver(char oType)
Determine which type of Observer is used. - t,T sets the Textobserver to active. - g,G sets the Graphicobserver to active (important only 750 elements are allowed) The Graphicobserver shows every move of an element (slow). The t Textobserver shows every move of an element (very slow with a great number of elements) the T Textobserver shows only the first and the last state.


replace

public void replace(int from,
                    int to)
Two array elements change their places. If the main class implements observers
the notifyObservers call will take effect.


equal

public boolean equal(int posOne,
                     int posTwo)
Two elements are compared. If element at index one is equal the element at index two true is returned
else false.


isGreater

public boolean isGreater(int pos,
                         int value)
One element of the array at position pos and the number value are compared. If element at pos one is greater than value true is returned
else false.


isLess

public boolean isLess(int pos,
                      int value)
One element of the array at position pos and the number value are compared. If element at pos one is less than value true is returned
else false.


isEqual

public boolean isEqual(int pos,
                       int value)
One element of the array at position pos and the number value are compared. If element at pos one is equal than value true is returned
else false.


less

public boolean less(int posOne,
                    int posTwo)
Two elements are compared. If element at index one is less than element at index two true is returned
else false.


greater

public boolean greater(int posOne,
                       int posTwo)
Two elements are compared. If element at index one is greater than element at index two true is returned
else false.


startClock

public void startClock()
The actual time is determined and saved.


stopClock

public void stopClock()
The actual time is determined and saved.


showTime

public void showTime()
The difference between the two saved timestamps is written to the terminal.


getElapsedTime

public java.lang.String getElapsedTime()
The actual elapsed time is returned as String


getStart

public int getStart()
The lowest array index is returned.


getStop

public int getStop()
The highest array index is returned.


fillRandom

public void fillRandom()
The array is filled with random numbers between 1 and the maximum
given by the constructor.


fillNormal

public void fillNormal()
Ordered filling with values from zero to maximum -1.


fillInvers

public void fillInvers()
Invers filling with values from maximum to zero.