LongSet
-
Cmn
sealed class LongSet
MutableLongSet |
|
LongSet is a container with a Set-like interface designed to avoid allocations, including boxing.
This implementation makes no guarantee as to the order of the elements, nor does it make guarantees that the order remains constant over time.
Though LongSet offers a read-only interface, it is always backed by a MutableLongSet. Read operations alone are thread-safe. However, any mutations done through the backing MutableLongSet while reading on another thread are not safe and the developer must protect the set from such changes during read operations.
| See also | |
|---|---|
MutableLongSet |
Summary
Protected constructors |
|
|---|---|
LongSet() |
Cmn
|
Public functions |
||
|---|---|---|
inline Boolean |
Returns true if all elements match the given |
Cmn
|
Boolean |
any()Returns |
Cmn
|
inline Boolean |
Returns true if at least one element matches the given |
Cmn
|
operator Boolean |
Returns |
Cmn
|
@IntRange(from = 0) Int |
count()Returns the number of elements in this set. |
Cmn
|
inline @IntRange(from = 0) Int |
Returns the number of elements matching the given |
Cmn
|
open operator Boolean |
Compares the specified object |
Cmn
|
inline Long |
first()Returns the first element in the collection. |
Cmn
|
inline Long |
Returns the first element in the collection for which |
Cmn
|
inline Unit |
Iterates over every element stored in this set by invoking the specified |
Cmn
|
open Int |
hashCode()Returns the hash code value for this set. |
Cmn
|
Boolean |
isEmpty()Indicates whether this set is empty. |
Cmn
|
Boolean |
Returns |
Cmn
|
String |
joinToString(Creates a String from the elements separated by |
Cmn
|
inline String |
joinToString(Creates a String from the elements separated by |
Cmn
|
Boolean |
none()Returns |
Cmn
|
open String |
toString()Returns a string representation of this set. |
Cmn
|
Public properties |
||
|---|---|---|
Int |
Returns the number of elements that can be stored in this set without requiring internal storage reallocation. |
Cmn
|
Int |
Returns the number of elements in this set. |
Cmn
|
Protected constructors
Public functions
all
inline fun all(predicate: (element: Long) -> Boolean): Boolean
Returns true if all elements match the given predicate.
any
inline fun any(predicate: (element: Long) -> Boolean): Boolean
Returns true if at least one element matches the given predicate.
contains
operator fun contains(element: Long): Boolean
Returns true if the specified element is present in this set, false otherwise.
| Parameters | |
|---|---|
element: Long |
The element to look for in this set |
count
inline fun count(predicate: (element: Long) -> Boolean): @IntRange(from = 0) Int
Returns the number of elements matching the given predicate.
equals
open operator fun equals(other: Any?): Boolean
Compares the specified object other with this set for equality. The two objects are considered equal if other:
first
inline fun first(): Long
Returns the first element in the collection.
| Throws | |
|---|---|
kotlin.NoSuchElementException |
if the collection is empty |
first
inline fun first(predicate: (element: Long) -> Boolean): Long
Returns the first element in the collection for which predicate returns true.
Note There is no mechanism for both determining if there is an element that matches predicate and returning it if it exists. Developers should use forEach to achieve this behavior.
| Parameters | |
|---|---|
predicate: (element: Long) -> Boolean |
Called on elements of the set, returning |
| Throws | |
|---|---|
kotlin.NoSuchElementException |
if |
forEach
inline fun forEach(block: (element: Long) -> Unit): Unit
Iterates over every element stored in this set by invoking the specified block lambda.
hashCode
open fun hashCode(): Int
Returns the hash code value for this set. The hash code of a set is defined to be the sum of the hash codes of the elements in the set.
joinToString
fun joinToString(
separator: CharSequence = ", ",
prefix: CharSequence = "",
postfix: CharSequence = "",
limit: Int = -1,
truncated: CharSequence = "..."
): String
Creates a String from the elements separated by separator and using prefix before and postfix after, if supplied.
When a non-negative value of limit is provided, a maximum of limit items are used to generate the string. If the collection holds more than limit items, the string is terminated with truncated.
joinToString
inline fun joinToString(
separator: CharSequence = ", ",
prefix: CharSequence = "",
postfix: CharSequence = "",
limit: Int = -1,
truncated: CharSequence = "...",
crossinline transform: (Long) -> CharSequence
): String
Creates a String from the elements separated by separator and using prefix before and postfix after, if supplied. transform dictates how each element will be represented.
When a non-negative value of limit is provided, a maximum of limit items are used to generate the string. If the collection holds more than limit items, the string is terminated with truncated.