trait Idempotent[A] extends Associative[A]
The Idempotent
type class describes a binary operator for a type A
that
is both associative and produces the same value when combining two identical values.
This means that a <> a
is equal to a
for all values a
.
Example of idempotent operations is union of sets, but not addition of integers.
Idempotent operators are useful because combining the values with an idempotent operation results in the same value regardless of the number of values are combined, allowing us to optimize out unnecessary combinations of the same values.
- Self Type
- Idempotent[A]
- Alphabetic
- By Inheritance
- Idempotent
- Associative
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
combine(l: ⇒ A, r: ⇒ A): A
- Definition Classes
- Associative
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
combineIdempotent(l: ⇒ A, r: ⇒ A)(implicit A: Equal[A]): A
If the values are equal, it doesn't attempt to combine them and promptly returns the first one.
If the values are equal, it doesn't attempt to combine them and promptly returns the first one. If not equal, the values are combined normally.
-
def
combineNormal(l: ⇒ A, r: ⇒ A): A
- Attributes
- protected
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
idempotent(implicit A: Equal[A]): Idempotent[A]
Creates a new instance which internally uses
combineIdempotent
for combining values. -
final
def
intersperse(middle: A): Associative[A]
- Definition Classes
- Associative
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
multiplyOption(n: Int)(a: A): Option[A]
- Definition Classes
- Associative
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
repeat(a: A)(n: Int): A
- Definition Classes
- Associative
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()