PartiallyOrderedSet

cats.collections.PartiallyOrderedSet
See thePartiallyOrderedSet companion object
trait PartiallyOrderedSet[F[_]] extends UnorderedFoldable[F]

This is a typeclass for Heap-like data-structures which are not totally ordered sets, but can produce the minimimum value, add and remove items.

Attributes

Companion:
object
Source:
PartiallyOrderedSet.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Abstract methods

def add[A](fa: F[A], a: A)(implicit order: Order[A]): F[A]

Add an item to fa

Add an item to fa

Attributes

Source:
PartiallyOrderedSet.scala
def contains[A](fa: F[A], a: A)(implicit order: Order[A]): Boolean

use the heap property to be more efficient than toSortedList to check containment

use the heap property to be more efficient than toSortedList to check containment

Attributes

Source:
PartiallyOrderedSet.scala
def empty[A]: F[A]

return an empty F

return an empty F

Attributes

Source:
PartiallyOrderedSet.scala
def minimumOption[A](fa: F[A]): Option[A]

Get the minimum value from fa if not empty

Get the minimum value from fa if not empty

Attributes

Source:
PartiallyOrderedSet.scala
def removeMin[A](fa: F[A])(implicit order: Order[A]): F[A]

Remove the minimum value if fa is not empty, else return empty

Remove the minimum value if fa is not empty, else return empty

Attributes

Source:
PartiallyOrderedSet.scala
def singleton[A](a: A): F[A]

make an f with a single item

make an f with a single item

Attributes

Source:
PartiallyOrderedSet.scala

Concrete methods

def addAll[A](fa: F[A], items: Iterable[A])(implicit order: Order[A]): F[A]

Attributes

Source:
PartiallyOrderedSet.scala
def addAllLargest[A](fa: F[A], maxSize: Long, items: Iterable[A])(implicit order: Order[A]): F[A]

same as items.foldLeft(fa)(addIfLarger(_, count, _))

same as items.foldLeft(fa)(addIfLarger(_, count, _))

Attributes

Source:
PartiallyOrderedSet.scala
def addIfLarger[A](fa: F[A], maxSize: Long, item: A)(implicit order: Order[A]): F[A]

same as takeLargest(add(fa, item), maxSize)

same as takeLargest(add(fa, item), maxSize)

Attributes

Source:
PartiallyOrderedSet.scala
def build[A](items: Iterable[A])(implicit order: Order[A]): F[A]

build an F from Iterable

build an F from Iterable

Attributes

Source:
PartiallyOrderedSet.scala
def order[A : Order]: Order[F[A]]

Given an Order[A] we can always make an Order[F[A]]

Given an Order[A] we can always make an Order[F[A]]

Attributes

Source:
PartiallyOrderedSet.scala
def pop[A](fa: F[A])(implicit order: Order[A]): Option[(A, F[A])]

Same as get the minimimumOption and removinging the minimum

Same as get the minimimumOption and removinging the minimum

Attributes

Source:
PartiallyOrderedSet.scala
def sortedFoldLeft[A, B](fa: F[A], init: B)(fn: (B, A) => B)(implicit order: Order[A]): B

fold in order

fold in order

Attributes

Source:
PartiallyOrderedSet.scala
def takeLargest[A](fa: F[A], maxSize: Long)(implicit order: Order[A]): F[A]

remove as many as needed until size <= maxSize

remove as many as needed until size <= maxSize

Attributes

Source:
PartiallyOrderedSet.scala
def toSortedList[A](fa: F[A])(implicit order: Order[A]): List[A]

return a sorted list of all items in fa

return a sorted list of all items in fa

Attributes

Source:
PartiallyOrderedSet.scala

Deprecated methods

def unadd[A](fa: F[A])(implicit order: Order[A]): Option[(A, F[A])]

Same as get the minimimumOption and removinging the minimum

Same as get the minimimumOption and removinging the minimum

Attributes

Deprecated
true
Source:
PartiallyOrderedSet.scala

Inherited methods

def contains_[A](fa: F[A], v: A)(implicit ev: Eq[A]): Boolean

Tests if fa contains v using the Eq instance for A

Tests if fa contains v using the Eq instance for A

Attributes

Inherited from:
UnorderedFoldable
Source:
UnorderedFoldable.scala
def count[A](fa: F[A])(p: A => Boolean): Long

Count the number of elements in the structure that satisfy the given predicate.

Count the number of elements in the structure that satisfy the given predicate.

For example:

scala> import cats.implicits._
scala> val map1 = Map[Int, String]()
scala> val p1: String => Boolean = _.length > 0
scala> UnorderedFoldable[Map[Int, *]].count(map1)(p1)
res0: Long = 0

scala> val map2 = Map(1 -> "hello", 2 -> "world", 3 -> "!")
scala> val p2: String => Boolean = _.length > 1
scala> UnorderedFoldable[Map[Int, *]].count(map2)(p2)
res1: Long = 2

Attributes

Inherited from:
UnorderedFoldable
Source:
UnorderedFoldable.scala
def exists[A](fa: F[A])(p: A => Boolean): Boolean

Check whether at least one element satisfies the predicate.

Check whether at least one element satisfies the predicate.

If there are no elements, the result is false.

Attributes

Inherited from:
UnorderedFoldable
Source:
UnorderedFoldable.scala
def forall[A](fa: F[A])(p: A => Boolean): Boolean

Check whether all elements satisfy the predicate.

Check whether all elements satisfy the predicate.

If there are no elements, the result is true.

Attributes

Inherited from:
UnorderedFoldable
Source:
UnorderedFoldable.scala
def isEmpty[A](fa: F[A]): Boolean

Returns true if there are no elements. Otherwise false.

Returns true if there are no elements. Otherwise false.

Attributes

Inherited from:
UnorderedFoldable
Source:
UnorderedFoldable.scala
def nonEmpty[A](fa: F[A]): Boolean

Attributes

Inherited from:
UnorderedFoldable
Source:
UnorderedFoldable.scala
def size[A](fa: F[A]): Long

The size of this UnorderedFoldable.

The size of this UnorderedFoldable.

This is overridden in structures that have more efficient size implementations (e.g. Vector, Set, Map).

Note: will not terminate for infinite-sized collections.

Attributes

Inherited from:
UnorderedFoldable
Source:
UnorderedFoldable.scala

Attributes

Inherited from:
UnorderedFoldable
Source:
UnorderedFoldable.scala
def unorderedFoldMap[A, B : CommutativeMonoid](fa: F[A])(f: A => B): B

Attributes

Inherited from:
UnorderedFoldable
Source:
UnorderedFoldable.scala