public class Ranking extends SimpleRanking
RankingPosition
instance) may be shared by one or more objects,
having the same evaluations (ex-equo).
Places and objects are numbered starting from zero, except from toString
method.
In textual form, which may be for example written to file,
places and objects are numbered starting from zero or from one, depending on incrementIndex
value.incrementIndex
Constructor | Description |
---|---|
Ranking(double[] objectsEvaluations) |
Constructor for
Ranking class.SIC! |
Ranking(java.util.ArrayList<RankingPosition> ranking) |
Constructor for
Ranking class. |
Ranking(java.util.Hashtable<java.lang.Integer,java.lang.Double> objectsEvaluations) |
Constructor for
Ranking class.SIC! |
Modifier and Type | Method | Description |
---|---|---|
double |
getEvaluationAtPlace(int place) |
Gets evaluation of all objects sharing ex-equo given place.
|
java.lang.String |
toString() |
Gets textual form of this ranking.
|
void |
writeRanking(java.lang.String fileName) |
Writes this ranking to file with given name (path).
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getNumbersOfObjectsAtPlace, getPlaceOfObject, getQuantityOfObjects, getQuantityOfPlaces, toSingleLineString
public Ranking(double[] objectsEvaluations)
Ranking
class.objectsEvaluations
- array with unordered objects' evaluations.
Index corresponds to object's index, value to object's evaluation.java.lang.NullPointerException
- when array of objects' evaluations is null
InvalidValueException
- when array of objects' evaluations is emptypublic Ranking(java.util.ArrayList<RankingPosition> ranking)
Ranking
class.
In given ranking each object's index can be present only at one place.
Given ranking is stored directly in this class.
Indices of objects sharing each place are getting sorted ascendingly.ranking
- array list containing RankingPosition
objects for subsequent places.
Index = place; value = RankingPosition
object storing indices of objects
sharing considered place and their common evaluationjava.lang.NullPointerException
- when ranking is null
InvalidValueException
- when ranking is emptypublic Ranking(java.util.Hashtable<java.lang.Integer,java.lang.Double> objectsEvaluations)
Ranking
class.objectsEvaluations
- hash table mapping indices of objects to their evaluationsjava.lang.NullPointerException
- when objects' evaluations are null
InvalidValueException
- when objects' evaluations are emptypublic double getEvaluationAtPlace(int place)
place
- place in ranking for which evaluation of objects sharing that place should be establishedjava.lang.IndexOutOfBoundsException
- when place is less than zero or greater than or equal to the quantity of all placespublic java.lang.String toString()
toString
in class SimpleRanking
public void writeRanking(java.lang.String fileName) throws java.io.IOException
writeRanking
in class SimpleRanking
fileName
- name (path) of the file in which this ranking should be savedjava.io.IOException
- if file with given name (path) can't be opened for write