ValueOps

com.phasmidsoftware.lascala.tree.ValueOps
trait ValueOps[K, V] extends Ordering[V]

This trait is implemented by a type class which pertains to the underlying VALUE type of a tree. It does not pertain to the shape of the tree.

Type parameters

K

the key type

V

the value type

Attributes

Graph
Supertypes
trait Ordering[V]
trait PartialOrdering[V]
trait Equiv[V]
trait Serializable
trait Comparator[V]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait StringValueOps[V]

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.

Value parameters

lhs

the left-hand side value for infix comparison operations

Attributes

Inherited from:
Ordering
Supertypes
class Object
trait Matchable
class Any

Value members

Abstract methods

def createValueFromKey(k: K, vo: => Option[V]): Option[V]

In the event that a parent cannot be found, we sometimes have to create a new node. This requires us to find a value for the new node

In the event that a parent cannot be found, we sometimes have to create a new node. This requires us to find a value for the new node

Value parameters

k

the key for the parent we must create

vo

an optional value from which the result may be inferred (as the parent), if possible.

Attributes

Returns

a value for the parent node, wrapped in Option

def getKeyAsParent(v: V): K

Extract a key from a value v but from a tree-structural point of view. I.e. the value returned should match the parent key of any children of this node. This key is used in the tree-building process, in particular, it is used solely (and indirectly) by the addNode method to find an appropriate node to which an additional node should be attached. It is used for no other purpose whatsoever.

Extract a key from a value v but from a tree-structural point of view. I.e. the value returned should match the parent key of any children of this node. This key is used in the tree-building process, in particular, it is used solely (and indirectly) by the addNode method to find an appropriate node to which an additional node should be attached. It is used for no other purpose whatsoever.

Value parameters

v

the value whose key we require

Attributes

Returns

the key

def getKeyFromValue(v: V): K

Extract the key from a value v (ignoring its actual position within the tree). This method is used strictly for lookup purposes, that's to say it is not used during the build-tree process for finding an appropriate parent for an additional node. If a tree is to be indexed, then this key value must be unique throughout the tree, otherwise confusion will arise -- just like in HashMap, for instance.

Extract the key from a value v (ignoring its actual position within the tree). This method is used strictly for lookup purposes, that's to say it is not used during the build-tree process for finding an appropriate parent for an additional node. If a tree is to be indexed, then this key value must be unique throughout the tree, otherwise confusion will arise -- just like in HashMap, for instance.

Value parameters

v

the value whose key we require

Attributes

Returns

the key

def getParentKey(v: V): Option[K]

If such a thing is defined for this type of value, get the parent key

If such a thing is defined for this type of value, get the parent key

Value parameters

v

the value whose parent key we desire

Attributes

Returns

an (optional) parent key

Inherited methods

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

Returns true if x == y in the ordering.

Returns true if x == y in the ordering.

Value parameters

x

the first value to compare

y

the second value to compare

Attributes

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

Returns true if x > y in the ordering.

Returns true if x > y in the ordering.

Value parameters

x

the first value to compare

y

the second value to compare

Attributes

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

Returns true if x >= y in the ordering.

Returns true if x >= y in the ordering.

Value parameters

x

the first value to compare

y

the second value to compare

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
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.

Value parameters

other

the ordering to check

Attributes

Returns

true if other is the reverse of this ordering, false otherwise

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

Returns true if x < y in the ordering.

Returns true if x < y in the ordering.

Value parameters

x

the first value to compare

y

the second value to compare

Attributes

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

Returns true if x <= y in the ordering.

Returns true if x <= y in the ordering.

Value parameters

x

the first value to compare

y

the second value to compare

Attributes

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

Returns x if x >= y, otherwise y.

Returns x if x >= y, otherwise y.

Type parameters

U

a subtype of T, used to preserve the specific type in the return value

Value parameters

x

the first candidate value

y

the second candidate value

Attributes

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

Returns x if x <= y, otherwise y.

Returns x if x <= y, otherwise y.

Type parameters

U

a subtype of T, used to preserve the specific type in the return value

Value parameters

x

the first candidate value

y

the second candidate value

Attributes

Inherited from:
Ordering
def on[U](f: U => V): 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[U, T: Ordering](x: U, y: U, f: U => T) = Ordering[T].compare(f(x), f(y))

Type parameters

U

the type of the values to be ordered

Value parameters

f

the function to extract a T value from a U value

Attributes

Returns

an Ordering[U] that orders values by applying f and comparing the results using this ordering

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

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

Returns

an Ordering[T] that uses this ordering first, falling back to other when values are equal

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: V => S)(implicit ord: Ordering[S]): Ordering[V]

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:

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

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

Type parameters

S

the type returned by the extraction function f

Value parameters

f

the function to extract a comparison key from a T value

ord

the implicit ordering for the extracted key type S

Attributes

Returns

an Ordering[T] that uses this ordering first, falling back to comparing by f when values are equal

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

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

Returns

an Ordering[T] that compares elements in the reverse order of this ordering

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

Attributes

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

Attributes

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

Attributes

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

Attributes

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

Attributes

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

Attributes

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

Attributes

Inherited from:
Comparator
def tryCompare(x: V, y: V): 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).

Value parameters

x

the first value to compare

y

the second value to compare

Attributes

Inherited from:
Ordering

Inherited and Abstract methods

def compare(x: V, y: V): 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)

Value parameters

x

the first value to compare

y

the second value to compare

Attributes

Returns

a negative integer, zero, or a positive integer as x is less than, equal to, or greater than y

Inherited from:
Ordering

Implicits

Inherited implicits

implicit def mkOrderingOps(lhs: V): 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.

Value parameters

lhs

the value to enrich with ordering operators

Attributes

Inherited from:
Ordering