Class ImmutableLinearPreferenceImpl
- java.lang.Object
-
- io.github.oliviercailloux.j_voting.preferences.classes.ImmutableLinearPreferenceImpl
-
- All Implemented Interfaces:
ImmutableCompletePreference,ImmutableLinearPreference,ImmutablePreference,Preference
public class ImmutableLinearPreferenceImpl extends Object implements ImmutableLinearPreference
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableList<ImmutableSet<Alternative>>asEquivalenceClasses()ImmutableGraph<Alternative>asGraph()In the graph : a relation from a to b means "a is at least as good as b".ImmutableList<Alternative>asList()Best alternatives coming first in the list.booleanequals(Object o2)ImmutableSet<Alternative>getAlternatives()The returned set reads through this object: if this object is mutable, any modification to this object modifies the returned set, and conversely.ImmutableSet<Alternative>getAlternatives(int rank)intgetRank(Alternative a)The rank of an alternative is one plus the number of alternatives strictly preferred to it.VotergetVoter()static ImmutableLinearPreferencegiven(Voter voter, List<Alternative> list)Best firststatic ImmutableLinearPreferencegiven(List<Alternative> list)Best firstinthashCode()StringtoString()
-
-
-
Method Detail
-
given
public static ImmutableLinearPreference given(List<Alternative> list)
Best first
-
given
public static ImmutableLinearPreference given(Voter voter, List<Alternative> list)
Best first
-
getVoter
public Voter getVoter()
- Specified by:
getVoterin interfacePreference- Returns:
Voterinstance of the preference, Returns the voter 0 if no specific voter is associated to this preference
-
getAlternatives
public ImmutableSet<Alternative> getAlternatives()
Description copied from interface:ImmutablePreferenceThe returned set reads through this object: if this object is mutable, any modification to this object modifies the returned set, and conversely. This set is immutable.- Specified by:
getAlternativesin interfaceImmutablePreference- Specified by:
getAlternativesin interfacePreference- Returns:
- alternatives's set
-
asList
public ImmutableList<Alternative> asList()
Description copied from interface:ImmutableLinearPreferenceBest alternatives coming first in the list.- Specified by:
asListin interfaceImmutableLinearPreference- Returns:
- a sorted list of alternatives corresponding to the preference.
-
getRank
public int getRank(Alternative a)
Description copied from interface:ImmutableCompletePreferenceThe rank of an alternative is one plus the number of alternatives strictly preferred to it.- Specified by:
getRankin interfaceImmutableCompletePreference- Parameters:
a- is anAlternative- Returns:
- the rank of this alternative (a number between 1 and n) where
n is the total number of
Alternativeinstances.
-
getAlternatives
public ImmutableSet<Alternative> getAlternatives(int rank)
- Specified by:
getAlternativesin interfaceImmutableCompletePreference- Parameters:
rank- at least 1.- Returns:
- the
Aternativeset at this rank. Empty set id there is no alternative at this rank.
-
asEquivalenceClasses
public ImmutableList<ImmutableSet<Alternative>> asEquivalenceClasses()
- Specified by:
asEquivalenceClassesin interfaceImmutableCompletePreference- Returns:
- Same data but in an Immutable list object A set of alternative is strictly prefered to next sets. All the alternatives in a set are considered ex-aequo.
-
asGraph
public ImmutableGraph<Alternative> asGraph()
Description copied from interface:ImmutablePreferenceIn the graph : a relation from a to b means "a is at least as good as b". This graph can’t be modified, but is not necessarily immutable. Reflexive and transitive. This graph is immutable.- Specified by:
asGraphin interfaceImmutablePreference- Specified by:
asGraphin interfacePreference- Returns:
- the Graph corresponding to the Preference.
-
-