Interface Ordered.OfBoolean

All Superinterfaces:
Arrangeable
All Known Implementing Classes:
BooleanBag, BooleanDeque, BooleanList
Enclosing interface:
Ordered<T>

public static interface Ordered.OfBoolean extends Arrangeable
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.github.tommyettinger.ds.Arrangeable

    Arrangeable.ArrangeableList<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    default OrderType
     
    Gets the BooleanList of boolean items that this data structure holds, in the order it uses for iteration.
    default boolean
    Returns a random item from the list, or false if the list is empty.
    default boolean
    Gets a random boolean value from this Ordered, using the given random number generator.
    default void
    removeRange(int start, int end)
    Removes items from the ordering (and potentially only the ordering, depending on implementation) between start, inclusive, and end, exclusive.
    default void
    Reverses the order of this Ordered in-place.
    default boolean
    selectRanked(BooleanComparator comparator, int kthLowest)
    Selects the kth-lowest element from this Ordered according to BooleanComparator ranking.
    default int
    selectRankedIndex(BooleanComparator comparator, int kthLowest)
    Gets the index of the kth-lowest element from this Ordered according to BooleanComparator ranking.
    default void
    Pseudo-randomly shuffles the order of this Ordered in-place.
    default void
    sort(BooleanComparator comparator)
    Sorts this Ordered according to the order induced by the specified BooleanComparator.
    default void
    swap(int first, int second)
    Switches the ordering of positions first and second, without changing any items beyond that.

    Methods inherited from interface com.github.tommyettinger.ds.Arrangeable

    rearrange, shuffle, size
  • Method Details

    • order

      BooleanList order()
      Gets the BooleanList of boolean items that this data structure holds, in the order it uses for iteration. This should usually return a direct reference to an BooleanList used inside this object, so changes to the list will affect this.
      Returns:
      the BooleanList of boolean items that this data structure holds
    • swap

      default void swap(int first, int second)
      Switches the ordering of positions first and second, without changing any items beyond that.
      Specified by:
      swap in interface Arrangeable
      Parameters:
      first - the first position, must not be negative and must be less than Arrangeable.size()
      second - the second position, must not be negative and must be less than Arrangeable.size()
    • shuffle

      default void shuffle(Random rng)
      Pseudo-randomly shuffles the order of this Ordered in-place. You can seed rng, the random number generator, with an identical seed to reproduce a shuffle on two Ordered with the same Arrangeable.size().
      Specified by:
      shuffle in interface Arrangeable
      Parameters:
      rng - any Random class, such as one from juniper
    • reverse

      default void reverse()
      Reverses the order of this Ordered in-place.
      Specified by:
      reverse in interface Arrangeable
    • random

      default boolean random()
      Returns a random item from the list, or false if the list is empty. Uses ArrayTools.RANDOM as its random number generator, which is randomly seeded.
      Returns:
      a randomly selected item from this, or false if this is empty
    • random

      default boolean random(Random rng)
      Gets a random boolean value from this Ordered, using the given random number generator.
      This should return false if the Ordered is empty.
      Parameters:
      rng - any Random class
      Returns:
      a random boolean value from this Ordered.OfBoolean
    • sort

      default void sort(BooleanComparator comparator)
      Sorts this Ordered according to the order induced by the specified BooleanComparator. The sort is stable: this method must not reorder equal elements.
      If the specified comparator is null then the numeric elements' natural ordering should be used.
      Parameters:
      comparator - used to sort the T items this contains; may be null to use natural ordering
    • selectRanked

      default boolean selectRanked(BooleanComparator comparator, int kthLowest)
      Selects the kth-lowest element from this Ordered according to BooleanComparator ranking. This might partially sort the Ordered, changing its order. The Ordered must have a size greater than 0, or a RuntimeException will be thrown.
      Parameters:
      comparator - used for comparison
      kthLowest - rank of desired object according to comparison; k is based on ordinal numbers, not array indices. For min value use 1, for max value use size of the Ordered; using 0 results in a runtime exception.
      Returns:
      the value of the kth lowest ranked item.
      See Also:
    • selectRankedIndex

      default int selectRankedIndex(BooleanComparator comparator, int kthLowest)
      Gets the index of the kth-lowest element from this Ordered according to BooleanComparator ranking. This might partially sort the Ordered, changing its order. The Ordered must have a size greater than 0, or a RuntimeException will be thrown.
      Parameters:
      comparator - used for comparison
      kthLowest - rank of desired object according to comparison; k is based on ordinal numbers, not array indices. For min value use 1, for max value use size of the Ordered; using 0 results in a runtime exception.
      Returns:
      the index of the kth lowest ranked item.
      See Also:
    • removeRange

      default void removeRange(int start, int end)
      Removes items from the ordering (and potentially only the ordering, depending on implementation) between start, inclusive, and end, exclusive.
      Parameters:
      start - inclusive start of the range to remove from the ordering
      end - exclusive end of the range to remove from the ordering
    • getOrderType

      default OrderType getOrderType()