Uses several instances of SplitSort, one for each axis considered, to sort media. More...
Collaboration diagram for sorter.Comparator:
[legend]Public Member Functions | |
| Comparator (Map< String, SplitSort > sorter, myDataBases.MySQLbase bdd) | |
Creates a Comparator instance using the SplitSorts contained in the sorter map and links it with a myDataBases.MySQLbase instance. <../..> | |
| Comparator (Map< String, SplitSort > sorter) | |
Creates a Comparator instance using the SplitSorts contained in the sorter map. <../..> | |
| Boolean | notFinished () |
Returns true while the sorting is not over. <../..> | |
| void | sortIteration () |
| Performs the first part of a quicksort iteration. <../..> | |
| void | endIteration () |
| Performs the last part of a quicksort iteration. <../..> | |
| void | demandNewComparisons (List< Integer > greater, List< Integer > smaller, List< String > axes) |
Asks for unknown comparisons by modifying the value of its parameters greater, smaller and axes. <../..> | |
| void | display () |
Displays the current state of the sort using SplitSort.display(). <../..> | |
| Map< String, SplitSort > | getSplitSorts () |
Returns the sorters attribute. <../..> | |
| Map< String, List< Integer[]> > | getCurrentState () |
Returns the current state of the sort, i.e a Map indexed by the axes and containing the sorted attribute of each SplitSort contained in sorters. <../..> | |
Private Attributes | |
| Map< String, SplitSort > | sorters |
This map must have the following structure : [ key = axis considered, element = instance of SplitSort in charge of sorting media along this axis ]. <../..> | |
| MySQLbase | sqlBase |
| The myDataBases.MySQLbase database from which comparisons will be retrieved. <../..> | |
Uses several instances of SplitSort, one for each axis considered, to sort media.
The aim of this class is to manage a SplitSort instance for each axis considered and to ask for all comparisons necessary at a time, i.e to "group" them in order to limit the number of jobs uploaded as well as allowing a treatment of the results requiring a lot of data to be processed at the same time.
A lot of its methods are simply calls to their equivalent for each SplitSort instance in the Comparator.sorters attribute.
Definition at line 19 of file Comparator.java.
| sorter.Comparator.Comparator | ( | Map< String, SplitSort > | sorter, |
| myDataBases.MySQLbase | bdd | ||
| ) |
Creates a Comparator instance using the SplitSorts contained in the sorter map and links it with a myDataBases.MySQLbase instance.
Both of the attributes of this class are set when this constructor is called.
| sorter | This map should have the following structure : [ key = axis considered, element = instance of SplitSort in charge of sorting media along this axis ]. |
| bdd | The database that will be used as the "sqlBase" attribute. |
Definition at line 51 of file Comparator.java.
| sorter.Comparator.Comparator | ( | Map< String, SplitSort > | sorter | ) |
Creates a Comparator instance using the SplitSorts contained in the sorter map.
This constructor sets the value the sorter attribute, but not that of the MySQLbase ! Be careful therefore not to do anything requiring it with such an instance.
| sorter | This map should have the following structure : [ key = axis considered, element = instance of SplitSort in charge of sorting media along this axis ]. |
Definition at line 67 of file Comparator.java.
{
this.sorters = sorter;
}
| void sorter.Comparator.demandNewComparisons | ( | List< Integer > | greater, |
| List< Integer > | smaller, | ||
| List< String > | axes | ||
| ) |
Asks for unknown comparisons by modifying the value of its parameters greater, smaller and axes.
Returns in the parameters greater and smaller the identifiers of the elements that require a comparison and are alleged to be respectively greater and smaller and, in axes, the axes along which the comparison must be performed.
| greater | All the media to be compared to the pivots in the several pending quicksorts. |
| smaller | The pivots corresponding to the several pending quicksorts. |
| axes | The axes along which comparisons must be performed. |
Definition at line 153 of file Comparator.java.
{
List<Integer> sortGreater = new ArrayList<Integer>();
List<Integer> sortSmaller = new ArrayList<Integer>();
greater.clear();
smaller.clear();
axes.clear();
for (Iterator<String> str = this.sorters.keySet().iterator(); str.hasNext();)
{
String emotion = str.next();
sortGreater = this.sorters.get(emotion).getGreater();
sortSmaller = this.sorters.get(emotion).getSmaller();
for (int i=0; i<sortGreater.size(); i++)
if ( sortGreater.get(i) != sortSmaller.get(i) )
if (this.sqlBase.alreadyDone(sortGreater.get(i), sortSmaller.get(i),emotion) == false)
{
greater.add(sortGreater.get(i));
smaller.add(sortSmaller.get(i));
axes.add(emotion);
}
}
}
| void sorter.Comparator.display | ( | ) |
Displays the current state of the sort using SplitSort.display().
Definition at line 181 of file Comparator.java.
| void sorter.Comparator.endIteration | ( | ) |
Performs the last part of a quicksort iteration.
All of the SplitSort instances contained in sorters are asked to perform the last step of a quicksort iteration.
Definition at line 120 of file Comparator.java.
{
List<Boolean> comparisons = new ArrayList<Boolean>();
List<Integer> greater = new ArrayList<Integer>();
List<Integer> smaller = new ArrayList<Integer>();
for (String axis : this.sorters.keySet() )
{
comparisons.clear();
greater = this.sorters.get(axis).getGreater();
smaller = this.sorters.get(axis).getSmaller();
for (int i=0; i<greater.size(); i++)
if (greater.get(i) == smaller.get(i))
comparisons.add(false);
else
comparisons.add( this.sqlBase.comparisonResult(greater.get(i),smaller.get(i),axis) );
this.sorters.get(axis).endIteration(comparisons);
}
}
| Map<String, List<Integer[]> > sorter.Comparator.getCurrentState | ( | ) |
Returns the current state of the sort, i.e a Map indexed by the axes and containing the sorted attribute of each SplitSort contained in sorters.
Definition at line 209 of file Comparator.java.
{
Map<String, List<Integer[]>> state = new Hashtable<String, List<Integer[]>>() ;
for(String axis : this.sorters.keySet())
state.put(axis, this.sorters.get(axis).getSorted());
return state;
}
| Map<String,SplitSort> sorter.Comparator.getSplitSorts | ( | ) |
Returns the sorters attribute.
Definition at line 199 of file Comparator.java.
{ return this.sorters; }
| Boolean sorter.Comparator.notFinished | ( | ) |
Returns true while the sorting is not over.
It equals false only if SplitSort.notFinished( ) is false for all the SplitSorts in sorters, in which case quicksort iterations must stop.
true if the sort must continue, false otherwise (case in which it is over). Definition at line 84 of file Comparator.java.
{
Boolean result = false;
for (Iterator<String> str = this.sorters.keySet().iterator(); str.hasNext();)
if (this.sorters.get(str.next()).notFinished() == true)
{
result = true;
break;
}
return result;
}
| void sorter.Comparator.sortIteration | ( | ) |
Performs the first part of a quicksort iteration.
All of the SplitSort instances contained in "sorters" are asked to perform the first step of a quicksort iteration.
Definition at line 103 of file Comparator.java.
Map<String,SplitSort> sorter.Comparator.sorters [private] |
This map must have the following structure : [ key = axis considered, element = instance of SplitSort in charge of sorting media along this axis ].
Definition at line 30 of file Comparator.java.
MySQLbase sorter.Comparator.sqlBase [private] |
The myDataBases.MySQLbase database from which comparisons will be retrieved.
Definition at line 34 of file Comparator.java.


