Skip to content

Commit

Permalink
fix: separate in from containsId
Browse files Browse the repository at this point in the history
  • Loading branch information
DanySK committed Feb 26, 2025
1 parent 9a42628 commit e079284
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package it.unibo.collektive.field.operations
import it.unibo.collektive.field.Field
import it.unibo.collektive.field.Field.Companion.fold
import it.unibo.collektive.field.Field.Companion.foldWithId
import kotlin.jvm.JvmName
import kotlin.jvm.JvmOverloads

/**
Expand All @@ -26,9 +25,8 @@ operator fun <ID : Any, T> Field<ID, T>.contains(value: T): Boolean = anyWithSel
* id in field.withoutSelf().keys
* ```
*/
@JvmName("containsId")
operator fun <ID : Any, T> Field<ID, T>.contains(id: ID): Boolean =
foldWithId(localValue == id) { current, id, _ -> current || id == id }
fun <ID : Any, T> Field<ID, T>.containsId(id: ID): Boolean =
foldWithId(localId == id) { current, id, _ -> current || id == id }

/**
* Count the number of elements in the field that satisfy the [predicate],
Expand Down Expand Up @@ -72,7 +70,7 @@ inline fun <ID : Any, T> Field<ID, T>.any(crossinline predicate: (T) -> Boolean)
* including the local value.
*/
inline fun <ID : Any, T> Field<ID, T>.anyWithSelf(crossinline predicate: (T) -> Boolean): Boolean =
any(predicate) || predicate(localValue)
predicate(localValue) || any(predicate)

/**
* Returns the element yielding the largest value of the given [comparator].
Expand Down

0 comments on commit e079284

Please sign in to comment.