HashSet

actual typealias HashSet<E> = HashSet<E> (source)

Platform and version requirements: Kotlin 1.1, JVM

open actual class HashSet<E> : 
    AbstractMutableSet<E>,
    MutableSet<E>
(source)

Platform and version requirements: JS

The implementation of the MutableSet interface, backed by a HashMap instance.

Constructors

<init>

HashSet()
HashSet(initialCapacity: Int, loadFactor: Float = 0.0f)

Constructs a new empty HashSet.

HashSet(elements: Collection<E>)

Constructs a new HashSet filled with the elements of the specified collection.

HashSet(initialCapacity: Int)

Properties

size

open actual val size: Int

Returns the size of the collection.

Functions

add

open actual fun add(element: E): Boolean

Adds the specified element to the collection.

clear

open actual fun clear()

Removes all elements from this collection.

contains

open operator actual fun contains(element: E): Boolean

Checks if the specified element is contained in this collection.

isEmpty

open actual fun isEmpty(): Boolean

Returns true if the collection is empty (contains no elements), false otherwise.

iterator

open actual fun iterator(): MutableIterator<E>

Returns an iterator over the elements of this object.

remove

open actual fun remove(element: E): Boolean

Removes a single instance of the specified element from this collection, if it is present.

Inherited Functions

equals

open fun equals(other: Any?): Boolean

Compares this set with another set instance with the unordered structural equality.

hashCode

open fun hashCode(): Int

Returns the hash code value for this set.

fun containsAll(
    elements: Collection<@UnsafeVariance E>
): Boolean
(source)

Overrides Set.containsAll

Overrides Collection.containsAll

Checks if all elements in the specified collection are contained in this collection.

fun addAll(elements: Collection<E>): Boolean (source)

Overrides MutableSet.addAll

Adds all of the elements in the specified collection to this collection.

Return true if any of the specified elements was added to the collection, false if the collection was not modified.

fun removeAll(elements: Collection<E>): Boolean (source)

Overrides MutableSet.removeAll

Removes all of this collection's elements that are also contained in the specified collection.

Return true if any of the specified elements was removed from the collection, false if the collection was not modified.

fun retainAll(elements: Collection<E>): Boolean (source)

Overrides MutableSet.retainAll

Retains only the elements in this collection that are contained in the specified collection.

Return true if any element was removed from the collection, false if the collection was not modified.