PriorityList

class PriorityList<T>(latterFirst: Boolean = true) : Iterable<T>

Constructors

Link copied to clipboard
constructor(latterFirst: Boolean = true)

Properties

Link copied to clipboard
val size: Int

Complexity: O(1)

Functions

Link copied to clipboard
fun add(value: T, priority: Int)

Adds value to the list with specified priority Complexity: O(log n)

Link copied to clipboard
fun addOrUpdatePriority(value: T, priority: Int)

If a value wasn't previously added to the list, simply adds it with a given priority. Otherwise, in case if priority is less or equal to the priority of existent element(s), does nothing. Otherwise, removes all existing elements from the list and adds value with a given priority. Complexity: O(n + k * log(n)) where k is a number of elements equal to value

Link copied to clipboard
fun clear()
Link copied to clipboard

All collection elements Complexity: O(n)

Link copied to clipboard

All elements with their priorities ordered by the time of adding (elements added earlier go first) Complexity: O(n log(n))

Link copied to clipboard
open fun forEach(p0: Consumer<in T>)
Link copied to clipboard
Link copied to clipboard
open operator override fun iterator(): Iterator<T>

Collection iterator Amortized next()/hasNext() complexity: O(1)

Link copied to clipboard
fun <T> Iterable<T>.joinToStringIndented(transform: (T) -> CharSequence? = null): String
Link copied to clipboard
fun remove(value: T)

Removes all values that are equal to value Complexity: O(n + k * log(n)) where k is a number of elements to remove

Link copied to clipboard
fun removeIf(predicate: (T) -> Boolean)
Link copied to clipboard