WeakHashSet

dotty.tools.dotc.util.WeakHashSet
See theWeakHashSet companion object
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.

Attributes

Companion
object
Graph
Supertypes
class MutableSet[A]
class ReadOnlySet[A]
class Object
trait Matchable
class Any
Known subtypes

Members list

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

Attributes

def -=(elem: A): Unit

Remove element x from the set

Remove element x from the set

Attributes

def clear(resetToInitial: Boolean): Unit

Remove all elements from this set.

Remove all elements from this set.

Value parameters

resetToInitial

If true, set back to initial configuration, which includes reallocating tables.

Attributes

override def iterator: Iterator[A]

Attributes

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.

Attributes

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.

Attributes

def size: Int

Inherited methods

def ++=(xs: IterableOnce[A]): Unit

Attributes

Inherited from:
MutableSet
def --=(xs: IterableOnce[A]): Unit

Attributes

Inherited from:
MutableSet
def add(x: A): Boolean

attempts to put x in the Set, if it was not entered before, return true, else return false. Overridden in GenericHashSet.

attempts to put x in the Set, if it was not entered before, return true, else return false. Overridden in GenericHashSet.

Attributes

Inherited from:
MutableSet
def contains(x: A): Boolean

Attributes

Inherited from:
ReadOnlySet
def foreach[U](f: A => U): Unit

Attributes

Inherited from:
ReadOnlySet

Attributes

Inherited from:
ReadOnlySet
def toList: List[A]

Attributes

Inherited from:
ReadOnlySet