Class OldLinearPreferenceImpl
- java.lang.Object
-
- io.github.oliviercailloux.j_voting.OldCompletePreferenceImpl
-
- io.github.oliviercailloux.j_voting.OldLinearPreferenceImpl
-
public class OldLinearPreferenceImpl extends OldCompletePreferenceImpl
This class is immutable Contains a list of Alternatives sorted by preferences Two alternatives can't be equally ranked You can't store the same alternative several times in the list Every alternative is an integer and corresponds to a voting choice
-
-
Field Summary
-
Fields inherited from class io.github.oliviercailloux.j_voting.OldCompletePreferenceImpl
preference
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OldLinearPreferenceImpl
createStrictCompletePreferenceImpl(List<Alternative> preference)
Factory method for StrictCompletePreferenceImplAlternative
getAlternative(Integer position)
List<Alternative>
getAlternatives()
static List<Set<Alternative>>
listAlternativeToListSetAlternative(List<Alternative> list)
static List<Alternative>
listSetAlternativeToList(List<Set<Alternative>> sets)
String
toString()
-
Methods inherited from class io.github.oliviercailloux.j_voting.OldCompletePreferenceImpl
contains, createCompletePreferenceImpl, equals, getAlternativeRank, getPreferencesNonStrict, hashCode, hasSameAlternatives, isIncludedIn, isStrict, size, size, toAlternativeSet, toStrictPreference
-
-
-
-
Method Detail
-
toString
public String toString()
- Overrides:
toString
in classOldCompletePreferenceImpl
-
getAlternatives
public List<Alternative> getAlternatives()
- Returns:
- a list of the alternatives by order of preference
-
listAlternativeToListSetAlternative
public static List<Set<Alternative>> listAlternativeToListSetAlternative(List<Alternative> list)
- Parameters:
list
- a list of alternatives notnull
- Returns:
- a list of set of alternatives. each set is composed of one alternative
-
listSetAlternativeToList
public static List<Alternative> listSetAlternativeToList(List<Set<Alternative>> sets)
- Parameters:
sets
- notnull
- Returns:
- a list of alternatives from a list of sets of alternatives.
-
createStrictCompletePreferenceImpl
public static OldLinearPreferenceImpl createStrictCompletePreferenceImpl(List<Alternative> preference)
Factory method for StrictCompletePreferenceImpl- Parameters:
preference
-not null
and all different alternatives- Returns:
- a new StrictCompletePreferenceImpl
-
getAlternative
public Alternative getAlternative(Integer position)
- Overrides:
getAlternative
in classOldCompletePreferenceImpl
- Parameters:
position
- notnull
- Returns:
- the alternative at the position given in the strict preference
-
-