Interface MutableLinearPreference

  • All Superinterfaces:
    Preference
    All Known Implementing Classes:
    MutableLinearPreferenceImpl, MutableStrictProfile.MutableLinearPreferenceDecorator

    public interface MutableLinearPreference
    extends Preference
    A mutable linear preference is a mutable antisymmetric complete preference. A mutable linear preference represents a linear order, or equivalently an antisymmetric complete order, or equivalently, the reduction of a weak-order. In this preference, it is possible to add alternatives and reorder them
    • Method Detail

      • changeOrder

        boolean changeOrder​(Alternative alternative,
                            int rank)
        Moves an existing alternative to the desired rank in the preference. All the intermediate alternatives shift. More precisely, the given alternative is swapped with its neighbor until it reaches the given rank.
        Parameters:
        alternative - that we're going to move in the preference
        rank - is the new rank where the alternative will be. The first alternative is at the rank 1. The rank must be less than 1 or greater than the rank of the last alternative.
        Returns:
        true if the preference has changed after this call. In other words, if the alternative was not already at this rank.
      • removeAlternative

        boolean removeAlternative​(Alternative alternative)
        Removes the specified alternative from this preference if it is present.
        Parameters:
        alternative - to be removed from this preference, if present
        Returns:
        true if this set contained the specified alternative
      • addAlternative

        boolean addAlternative​(Alternative alternative)
        Adds the specified alternative at the last rank of this preference if it is not already present.
        Parameters:
        alternative - to be added to this preference
        Returns:
        true if this preference did not already contain the specified alternative
      • swap

        boolean swap​(Alternative alternative1,
                     Alternative alternative2)
        This method enables to swap 2 alternatives of the preference. (If the specified alternatives are equal, invoking this method leaves the preference unchanged.)
        Parameters:
        alternative1 - that will change places with alternative2
        alternative2 - that will change places with alternative1
        Returns:
        true if the preference has changed after this call (and, thus, the alternatives are contained in this preference). Or equivalently, false if the specified alternatives are equal and contained in this preference.