Sorter
Class SplitSort

java.lang.Object
  extended by Sorter.SplitSort

public class SplitSort
extends java.lang.Object

Class SplitSort

Author:
Léo Perrin (Centrale Lyon)

Field Summary
private  java.util.List<java.lang.Boolean> comparisons
          Contains true at the rank k if the k^th element of "greater" IS actually greater than that of "smaller" : this.comparisons.get(k) = ( this.greater.get(k) > this.smaller.get(k) ), where ">" does NOT correspond to a comparison between integers but to the one performed by the turkers.
private  java.util.List<java.lang.Integer> greater
          Contains all the elements that are to be compared with their corresponding pivot.
private  java.lang.Integer minimalSize
          An array of a length smaller than minimalSize will not be sorted.
private  java.lang.Integer numberOfElements
          The number of elements contained in the initial array to sort.
private  java.util.List<java.lang.Integer> smaller
          Contains all the pivots used in the current iteration of the quicksort.
private  java.util.List<java.lang.Integer[]> sorted
          Contains the elements to be sorted in a list of arrays.
 
Constructor Summary
SplitSort(java.lang.Integer[] init, java.lang.Integer min)
          Creates an instance of SplitSort.
 
Method Summary
 void addComparisons(java.lang.Integer[] tab)
          Add the comparisons necessary to perform a quicksort on the array "tab" to the attributes "greater" and "smaller".
 void display()
          Prints the content of "sorted" on the screen, using brackets [] to separate each array.
 void endIteration(java.util.List<java.lang.Boolean> comparisons)
          Performs the end of the quicksort iteration on all of the arrays contained in the attribute list "sorted".
 java.util.List<java.lang.Boolean> getComparisons()
          Get the value of comparisons Contains true at the rank k if the k^th element of "greater" IS actually greater than that of "smaller" : this.comparisons.get(k) = ( this.greater.get(k) > this.smaller.get(k) ), where ">" does NOT correspond to a comparison between integers but to the one performed by the turkers.
 java.lang.Integer[] getFinalResult()
          Returns the content of sorted transferred in a simple array.
 java.util.List<java.lang.Integer> getGreater()
          Get the value of greater Contains all the elements that are to be compared with their corresponding pivot.
 java.util.List<java.lang.Integer> getSmaller()
          Get the value of smaller Contains all the pivots used in the current iteration of the quicksort.
 int insertion(int rank)
          Delete the array A at the "rank" rank in "sorted" and inserts arrays in it corresponding to the arrays of those "smaller than the pivot", the pivot and those "bigger than the pivot" contained in A.
 void iteration()
          Performs the first part of an iteration of the quicksort on all the arrays contained in "sorted", which means choosing a pivot in each one and generating all of the comparisons necessary to go further.
 java.lang.Boolean notFinished()
          Returns true if the number of elements contained in successive arrays containing less than this.minimalSize elements equals the number of elements to be sorted.
 void setComparisons(java.util.List<java.lang.Boolean> newVar)
          Set the value of comparisons Contains true at the rank k if the k^th element of "greater" IS actually greater than that of "smaller" : this.comparisons.get(k) = ( this.greater.get(k) > this.smaller.get(k) ), where ">" does NOT correspond to a comparison between integers but to the one performed by the turkers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

greater

private java.util.List<java.lang.Integer> greater
Contains all the elements that are to be compared with their corresponding pivot. These inside this list are alleged to be greater than their counterpart in the "smaller" list.


smaller

private java.util.List<java.lang.Integer> smaller
Contains all the pivots used in the current iteration of the quicksort. The media whose ID are inside this list are alleged to be smaller than their counterpart in the "greater" list.


sorted

private java.util.List<java.lang.Integer[]> sorted
Contains the elements to be sorted in a list of arrays. Each array will go through an iteration of the quicksort. For further details (and graphical explanations), see the documentation.


comparisons

private java.util.List<java.lang.Boolean> comparisons
Contains true at the rank k if the k^th element of "greater" IS actually greater than that of "smaller" : this.comparisons.get(k) = ( this.greater.get(k) > this.smaller.get(k) ), where ">" does NOT correspond to a comparison between integers but to the one performed by the turkers.


numberOfElements

private java.lang.Integer numberOfElements
The number of elements contained in the initial array to sort.


minimalSize

private java.lang.Integer minimalSize
An array of a length smaller than minimalSize will not be sorted.

Constructor Detail

SplitSort

public SplitSort(java.lang.Integer[] init,
                 java.lang.Integer min)
Creates an instance of SplitSort.

Parameters:
min - An Integer representing the minimal size of the arrays to be sorted.
init - An array containing the id (Integers) of the elements to sort.
Method Detail

notFinished

public java.lang.Boolean notFinished()
Returns true if the number of elements contained in successive arrays containing less than this.minimalSize elements equals the number of elements to be sorted.


iteration

public void iteration()
Performs the first part of an iteration of the quicksort on all the arrays contained in "sorted", which means choosing a pivot in each one and generating all of the comparisons necessary to go further.


addComparisons

public void addComparisons(java.lang.Integer[] tab)
Add the comparisons necessary to perform a quicksort on the array "tab" to the attributes "greater" and "smaller".

Parameters:
tab - The array that will go through an iteration of quicksort (using a pivot).

endIteration

public void endIteration(java.util.List<java.lang.Boolean> comparisons)
Performs the end of the quicksort iteration on all of the arrays contained in the attribute list "sorted".

Parameters:
comparisons -

insertion

public int insertion(int rank)
Delete the array A at the "rank" rank in "sorted" and inserts arrays in it corresponding to the arrays of those "smaller than the pivot", the pivot and those "bigger than the pivot" contained in A. Returns the number of arrays actually inserted.

Parameters:
rank - The array at the "rank" rank in the list "sorted" will be split in several parts.
Returns:
int

getFinalResult

public java.lang.Integer[] getFinalResult()
Returns the content of sorted transferred in a simple array.

Returns:
Integer[]

display

public void display()
Prints the content of "sorted" on the screen, using brackets [] to separate each array.


getGreater

public java.util.List<java.lang.Integer> getGreater()
Get the value of greater Contains all the elements that are to be compared with their corresponding pivot. These inside this list are alleged to be greater than their counterpart in the "smaller" list.

Returns:
the value of greater

getSmaller

public java.util.List<java.lang.Integer> getSmaller()
Get the value of smaller Contains all the pivots used in the current iteration of the quicksort. The media whose ID are inside this list are alleged to be smaller than their counterpart in the "greater" list.

Returns:
the value of smaller

setComparisons

public void setComparisons(java.util.List<java.lang.Boolean> newVar)
Set the value of comparisons Contains true at the rank k if the k^th element of "greater" IS actually greater than that of "smaller" : this.comparisons.get(k) = ( this.greater.get(k) > this.smaller.get(k) ), where ">" does NOT correspond to a comparison between integers but to the one performed by the turkers.

Parameters:
newVar - the new value of comparisons

getComparisons

public java.util.List<java.lang.Boolean> getComparisons()
Get the value of comparisons Contains true at the rank k if the k^th element of "greater" IS actually greater than that of "smaller" : this.comparisons.get(k) = ( this.greater.get(k) > this.smaller.get(k) ), where ">" does NOT correspond to a comparison between integers but to the one performed by the turkers.

Returns:
the value of comparisons