Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ericeil committed May 16, 2024
1 parent 8893055 commit 05a39a1
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions collect/src/main/kotlin/com/certora/collect/TreapSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public sealed interface TreapSet<out T> : PersistentSet<T> {
override fun builder(): Builder<@UnsafeVariance T> = TreapSetBuilder(this)

/**
Checks if this set contains any of the given [elements]. This is equivalent to, but more efficient than,
`this.intersect(elements).isNotEmpty()`.
Checks if this set contains any of the given [elements].
This is equivalent to, but more efficient than, `this.intersect(elements).isNotEmpty()`.
*/
public fun containsAny(elements: Iterable<@UnsafeVariance T>): Boolean

Expand All @@ -43,17 +44,34 @@ public sealed interface TreapSet<out T> : PersistentSet<T> {

/**
If this set contains an element that compares equal to the specified [element], returns that element instance.
This is useful for implementing intern tables, for example.
*/
public fun findEqual(element: @UnsafeVariance T): T?

/**
Calls [action] for each element in the set. This traverses the treap without allocating temporary storage,
which may be more efficient than [forEach].
Calls [action] for each element in the set.
This traverses the treap without allocating temporary storage, which may be more efficient than [forEach].
*/
public fun forEachElement(action: (element: T) -> Unit): Unit

/**
Calls [map] for each element in the set, and then reduces the results with [reduce].
This traverses the treap without allocating temporary storage, which may be more efficient than using the [map]
and [reduce] functions.
*/
public fun <R : Any> mapReduce(map: (T) -> R, reduce: (R, R) -> R): R?

/**
Calls [map] for each element in the set, and then reduces the results with [reduce].
Operations are performed in parallel for sets larger than (approximately) 2^parallelThresholdLog2.
This traverses the treap without allocating temporary storage, which may be more efficient than using the [map]
and [reduce] functions.
*/
public fun <R : Any> parallelMapReduce(map: (T) -> R, reduce: (R, R) -> R, parallelThresholdLog2: Int = 5): R?
}

Expand Down

0 comments on commit 05a39a1

Please sign in to comment.