Relation

trait Relation[A, B]

Binary relation between A and B. It is a set of pairs (_1, _2) for _1 in A, _2 in B.

Companion:
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def +(pair: (A, B)): Relation[A, B]

Includes pair in the relation.

Includes pair in the relation.

def +(a: A, b: B): Relation[A, B]

Includes (a, b) in the relation.

Includes (a, b) in the relation.

def +(a: A, bs: Iterable[B]): Relation[A, B]

Includes in the relation (a, b) for all b in bs.

Includes in the relation (a, b) for all b in bs.

def ++(r: Relation[A, B]): Relation[A, B]

Returns the union of the relation r with this relation.

Returns the union of the relation r with this relation.

def ++(rs: Iterable[(A, B)]): Relation[A, B]

Includes the given pairs in this relation.

Includes the given pairs in this relation.

def -(_1: A): Relation[A, B]

Removes all pairs (_1, _2) from this relation.

Removes all pairs (_1, _2) from this relation.

def -(pair: (A, B)): Relation[A, B]

Removes pair from this relation.

Removes pair from this relation.

def --(_1s: Iterable[A]): Relation[A, B]

Removes all elements (_1, _2) for all _1 in _1s from this relation.

Removes all elements (_1, _2) for all _1 in _1s from this relation.

def --(pairs: IterableOnce[(A, B)]): Relation[A, B]

Removes all pairs from this relation.

Removes all pairs from this relation.

def --(relations: Relation[A, B]): Relation[A, B]

Removes all relations from this relation.

Removes all relations from this relation.

def _1s: Set[A]

Returns the set of all _1s such that (_1, _2) is in this relation.

Returns the set of all _1s such that (_1, _2) is in this relation.

def _2s: Set[B]

Returns the set of all _2s such that (_1, _2) is in this relation.

Returns the set of all _2s such that (_1, _2) is in this relation.

def all: Iterable[(A, B)]

Returns all pairs in this relation.

Returns all pairs in this relation.

def contains(a: A, b: B): Boolean

Returns true iff (a,b) is in this relation

Returns true iff (a,b) is in this relation

def filter(f: (A, B) => Boolean): Relation[A, B]

Returns a relation with only pairs (a,b) for which f(a,b) is true.

Returns a relation with only pairs (a,b) for which f(a,b) is true.

def forward(_1: A): Set[B]

Returns the set of all _2s such that (_1, _2) is in this relation.

Returns the set of all _2s such that (_1, _2) is in this relation.

def forwardMap: Map[A, Set[B]]

Represents this relation as a Map from a _1 to the set of _2s such that (_1, _2) is in this relation.

Represents this relation as a Map from a _1 to the set of _2s such that (_1, _2) is in this relation.

Specifically, there is one entry for each _1 such that (_1, _2) is in this relation for some _2. The value associated with a given _1 is the set of all _2s such that (_1, _2) is in this relation.

def groupBy[K](discriminator: ((A, B)) => K): Map[K, Relation[A, B]]

Partitions this relation into a map of relations according to some discriminator function.

Partitions this relation into a map of relations according to some discriminator function.

def partition(f: (A, B) => Boolean): (Relation[A, B], Relation[A, B])

Returns a pair of relations: the first contains only pairs (a,b) for which f(a,b) is true and the other only pairs (a,b) for which f(a,b) is false.

Returns a pair of relations: the first contains only pairs (a,b) for which f(a,b) is true and the other only pairs (a,b) for which f(a,b) is false.

def reverse(_2: B): Set[A]

Returns the set of all _1s such that (_1, _2) is in this relation.

Returns the set of all _1s such that (_1, _2) is in this relation.

def reverseMap: Map[B, Set[A]]

Represents this relation as a Map from a _2 to the set of _1s such that (_1, _2) is in this relation.

Represents this relation as a Map from a _2 to the set of _1s such that (_1, _2) is in this relation.

Specifically, there is one entry for each _2 such that (_1, _2) is in this relation for some _1. The value associated with a given _2 is the set of all _1s such that (_1, _2) is in this relation.

def size: Int

Returns the number of pairs in this relation

Returns the number of pairs in this relation