OrderedSemiring

com.alecdorrington.scalgebra.ordered.OrderedSemiring
See theOrderedSemiring companion object

An ordered version of Semiring.

Attributes

Companion
object
Experimental
true
Graph
Supertypes
trait Ordering[X]
trait PartialOrdering[X]
trait Equiv[X]
trait Serializable
trait Comparator[X]
trait Semiring[X]
trait AdditiveMonoid[X]
trait AdditiveIdentity[X]
class Object
trait Matchable
class Any
Show all
Known subtypes

Members list

Type members

Inherited classlikes

class OrderingOps(lhs: Ordering.this.T)

This inner class defines comparison operators available for T.

This inner class defines comparison operators available for T.

It can't extend AnyVal because it is not a top-level class or a member of a statically accessible object.

Attributes

Inherited from:
Ordering
Supertypes
class Object
trait Matchable
class Any

Value members

Inherited methods

override def equiv(x: X, y: X): Boolean

Returns true if x == y in the ordering.

Returns true if x == y in the ordering.

Attributes

Definition Classes
Ordering -> PartialOrdering -> Equiv
Inherited from:
Ordering
override def gt(x: X, y: X): Boolean

Returns true if x > y in the ordering.

Returns true if x > y in the ordering.

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
override def gteq(x: X, y: X): Boolean

Returns true if x >= y in the ordering.

Returns true if x >= y in the ordering.

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
final inline def isNegative(x: X): Boolean

Attributes

Returns

true if a value x is strictly negative, i.e. x < 0.

Inherited from:
OrderedAdditiveIdentity
final inline def isNonNegative(x: X): Boolean

Attributes

Returns

true if a value x is positive or zero, i.e. x ≥ 0.

Inherited from:
OrderedAdditiveIdentity
final inline def isNonPositive(x: X): Boolean

Attributes

Returns

true if a value x is negative or zero, i.e. x ≤ 0.

Inherited from:
OrderedAdditiveIdentity
final inline def isPositive(x: X): Boolean

Attributes

Returns

true if a value x is strictly positive, i.e. x > 0.

Inherited from:
OrderedAdditiveIdentity
def isReverseOf(other: Ordering[_]): Boolean

Returns whether or not the other ordering is the opposite ordering of this one.

Returns whether or not the other ordering is the opposite ordering of this one.

Equivalent to other == this.reverse.

Implementations should only override this method if they are overriding reverse as well.

Attributes

Inherited from:
Ordering
override def lt(x: X, y: X): Boolean

Returns true if x < y in the ordering.

Returns true if x < y in the ordering.

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
override def lteq(x: X, y: X): Boolean

Returns true if x <= y in the ordering.

Returns true if x <= y in the ordering.

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
def max[U <: X](x: U, y: U): U

Returns x if x >= y, otherwise y.

Returns x if x >= y, otherwise y.

Attributes

Inherited from:
Ordering
def min[U <: X](x: U, y: U): U

Returns x if x <= y, otherwise y.

Returns x if x <= y, otherwise y.

Attributes

Inherited from:
Ordering
def on[U](f: U => X): Ordering[U]

Given f, a function from U into T, creates an Ordering[U] whose compare function is equivalent to:

Given f, a function from U into T, creates an Ordering[U] whose compare function is equivalent to:

def compare(x:U, y:U) = Ordering[T].compare(f(x), f(y))

Attributes

Inherited from:
Ordering
def orElse(other: Ordering[X]): Ordering[X]

Creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else the result of others compare function.

Creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else the result of others compare function.

Value parameters

other

an Ordering to use if this Ordering returns zero

Attributes

Example
case class Pair(a: Int, b: Int)
val pairOrdering = Ordering.by[Pair, Int](_.a)
                          .orElse(Ordering.by[Pair, Int](_.b))
Inherited from:
Ordering
def orElseBy[S](f: X => S)(implicit ord: Ordering[S]): Ordering[X]

Given f, a function from T into S, creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else a result equivalent to:

Given f, a function from T into S, creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else a result equivalent to:

Ordering[S].compare(f(x), f(y))

This function is equivalent to passing the result of Ordering.by(f) to orElse.

Attributes

Example
case class Pair(a: Int, b: Int)
val pairOrdering = Ordering.by[Pair, Int](_.a)
                          .orElseBy[Int](_.b)
Inherited from:
Ordering
override def pow(x: X, n: Int): X

Computes x raised to the power n, for any non-negative n.

Computes x raised to the power n, for any non-negative n.

Attributes

Throws
IllegalArgumentException

if n < 0.

Definition Classes
Inherited from:
MultiplicativeMonoid
final inline def product(x: X, xs: X*): X

Computes the product of x and all values in xss, i.e. x × xs₁ × xs₂ × ….

Computes the product of x and all values in xss, i.e. x × xs₁ × xs₂ × ….

Attributes

Inherited from:
MultiplicativeSemigroup
final inline def product(xs: Iterable[X]): X

Computes the product of all values in xs, i.e. xs₁ × xs₂ × …, or else one if xs is empty.

Computes the product of all values in xs, i.e. xs₁ × xs₂ × …, or else one if xs is empty.

Attributes

Inherited from:
MultiplicativeMonoid
final inline def productOption(xs: Iterable[X]): Option[X]

Computes the product of all values in xs, i.e. xs₁ × xs₂ × …, or else None if xs is empty.

Computes the product of all values in xs, i.e. xs₁ × xs₂ × …, or else None if xs is empty.

Attributes

Inherited from:
MultiplicativeSemigroup
override def reverse: Ordering[X]

Returns the opposite ordering of this one.

Returns the opposite ordering of this one.

Implementations overriding this method MUST override isReverseOf as well if they change the behavior at all (for example, caching does not require overriding it).

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
def reversed(): Comparator[X]

Attributes

Inherited from:
Comparator
override def scale(x: X, n: Int): X

Computes x multiplied by n, for any non-negative n.

Computes x multiplied by n, for any non-negative n.

Attributes

Throws
IllegalArgumentException

if n < 0.

Definition Classes
Inherited from:
AdditiveMonoid
final inline def sum(x: X, xs: X*): X

Computes the sum of x and all values in xs, i.e. x + xs₁ + xs₂ + ….

Computes the sum of x and all values in xs, i.e. x + xs₁ + xs₂ + ….

Attributes

Inherited from:
AdditiveSemigroup
final inline def sum(xs: Iterable[X]): X

Computes the sum of all values in xs, i.e. xs₁ + xs₂ + …, or else zero if xs is empty.

Computes the sum of all values in xs, i.e. xs₁ + xs₂ + …, or else zero if xs is empty.

Attributes

Inherited from:
AdditiveMonoid
final def sumOption(xs: Iterable[X]): Option[X]

Computes the sum of all values in xs, i.e. xs₁ + xs₂ + …, or else None if xs is empty.

Computes the sum of all values in xs, i.e. xs₁ + xs₂ + …, or else None if xs is empty.

Attributes

Inherited from:
AdditiveSemigroup
def thenComparing[U <: Comparable[_ >: U <: <FromJavaObject>]](x$0: Function[_ >: X <: <FromJavaObject>, _ <: U]): Comparator[X]

Attributes

Inherited from:
Comparator
def thenComparing[U <: <FromJavaObject>](x$0: Function[_ >: X <: <FromJavaObject>, _ <: U], x$1: Comparator[_ >: U <: <FromJavaObject>]): Comparator[X]

Attributes

Inherited from:
Comparator
def thenComparing(x$0: Comparator[_ >: X <: <FromJavaObject>]): Comparator[X]

Attributes

Inherited from:
Comparator
def thenComparingDouble(x$0: ToDoubleFunction[_ >: X <: <FromJavaObject>]): Comparator[X]

Attributes

Inherited from:
Comparator
def thenComparingInt(x$0: ToIntFunction[_ >: X <: <FromJavaObject>]): Comparator[X]

Attributes

Inherited from:
Comparator
def thenComparingLong(x$0: ToLongFunction[_ >: X <: <FromJavaObject>]): Comparator[X]

Attributes

Inherited from:
Comparator
def tryCompare(x: X, y: X): Some[Int]

Returns whether a comparison between x and y is defined, and if so the result of compare(x, y).

Returns whether a comparison between x and y is defined, and if so the result of compare(x, y).

Attributes

Inherited from:
Ordering
def two: X

The unique representation of 2 in this algebra system.

The unique representation of 2 in this algebra system.

Attributes

Inherited from:
Semiring

Inherited and Abstract methods

def add(x: X, y: X): X

Computes the sum of two values x and y, i.e. x + y.

Computes the sum of two values x and y, i.e. x + y.

Attributes

Note

All implementations must be associative, i.e. (x + y) + z == x + (y + z).

Inherited from:
AdditiveSemigroup
def compare(x: X, y: X): Int

Returns an integer whose sign communicates how x compares to y.

Returns an integer whose sign communicates how x compares to y.

The result sign has the following meaning:

  • negative if x < y
  • positive if x > y
  • zero otherwise (if x == y)

Attributes

Inherited from:
Ordering
def multiply(x: X, y: X): X

Computes the product of two values x and y, i.e. x × y.

Computes the product of two values x and y, i.e. x × y.

Attributes

Note

All implementations must be associative, i.e. (x × y) × z == x × (y × z).

Inherited from:
MultiplicativeSemigroup
def one: X

The unique representation of the multiplicative identity (1) in this algebra system. Typically corresponds to values such as 1 or 1.0F.

The unique representation of the multiplicative identity (1) in this algebra system. Typically corresponds to values such as 1 or 1.0F.

Attributes

Note

All implementations must obey the identity property, i.e. x × one == one × x == x.

Inherited from:
MultiplicativeIdentity
def zero: X

The unique representation of the additive identity (0) in this algebra system. Typically corresponds to values such as 0, 0.0F, or Seq.empty.

The unique representation of the additive identity (0) in this algebra system. Typically corresponds to values such as 0, 0.0F, or Seq.empty.

Attributes

Note

All implementations must obey the identity property, i.e. x + zero == zero + x == x.

Inherited from:
AdditiveIdentity

Implicits

Inherited implicits

implicit def mkOrderingOps(lhs: X): OrderingOps

This implicit method augments T with the comparison operators defined in scala.math.Ordering.Ops.

This implicit method augments T with the comparison operators defined in scala.math.Ordering.Ops.

Attributes

Inherited from:
Ordering