WeakHashSet

abstract class WeakHashSet[A <: AnyRef](initialCapacity: Int, loadFactor: Double) extends MutableSet[A]

A HashSet where the elements are stored weakly. Elements in this set are eligible for GC if no other hard references are associated with them. Its primary use case is as a canonical reference identity holder (aka "hash-consing") via findEntryOrUpdate

This Set implementation cannot hold null. Any attempt to put a null in it will result in a NullPointerException

This set implementation is not in general thread safe without external concurrency control. However it behaves properly when GC concurrently collects elements in this set.

Companion:
object
class MutableSet[A]
class ReadOnlySet[A]
class Object
trait Matchable
class Any

Type members

Types

type This = WeakHashSet[A]

Value members

Concrete methods

def +=(elem: A): Unit

Add element x to the set

Add element x to the set

def -=(elem: A): Unit

Remove element x from the set

Remove element x from the set

def clear(): Unit
override def iterator: Iterator[A]
Definition Classes
def lookup(elem: A): A | Null

The entry in the set such that isEqual(x, entry), or else null.

The entry in the set such that isEqual(x, entry), or else null.

def put(elem: A): A

Like += but return existing element equal to x of it exists, x itself otherwise.

Like += but return existing element equal to x of it exists, x itself otherwise.

def size: Int

Inherited methods

def ++=(xs: IterableOnce[A]): Unit
Inherited from:
MutableSet
def --=(xs: IterableOnce[A]): Unit
Inherited from:
MutableSet
def contains(x: A): Boolean
Inherited from:
ReadOnlySet
def foreach[U](f: A => U): Unit
Inherited from:
ReadOnlySet
Inherited from:
ReadOnlySet
def toList: List[T]
Inherited from:
ReadOnlySet