Dotty Documentation

0.5.0-bin-SNAPSHOT

final class WeakHashSet [ A ]
extends Set with Function1 with Set

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.

[-] Constructors

WeakHashSet ( initialCapacity: Int , loadFactor: Double )
WeakHashSet ( )

[-] Members

[+] class Diagnostics

Diagnostic information about the internals of this set. Not normally needed by ordinary code, but may be useful for diagnosing performance problems

[+] type This = WeakHashSet [ A ]
[+] private var count : Int

the number of elements in this set

[+] val initialCapacity : Int
[+] val loadFactor : Double
[+] private val queue : ReferenceQueue [ A ]

queue of Entries that hold elements scheduled for GC the removeStaleEntries() method works through the queue to remove stale entries from the table

[+] private var table : Array [ Entry [ A ] ]

the underlying table of entries which is an array of Entry linked lists

[+] private var threshold : Int

the limit at which we'll increase the size of the hash table

[+] override def + ( elem: A ) : WeakHashSet [ A ]
[+] def += ( elem: A ) : WeakHashSet [ A ]
[+] override def - ( elem: A ) : WeakHashSet [ A ]
[+] def -= ( elem: A ) : WeakHashSet [ A ]
[+] override def addEntry ( x: A ) : Unit
[+] override def apply ( x: A ) : Boolean
[+] private def bucketFor ( hash: Int ) : Int

find the bucket associated with an element's hash code

[+] override def clear ( ) : Unit
[+] private def computeCapacity : Int

from a specified initial capacity compute the capacity we'll use as being the next power of two equal to or greater than the specified initial capacity

[+] private def computeThreshold : Int
[+] def diagnostics : Diagnostics
[+] override def empty : This
[+] override def findEntry ( elem: A ) : A
[+] def findEntryOrUpdate ( elem: A ) : A
[+] override def foreach ( f: A => U ) : Unit
[+] override def iterator : Iterator [ A ]
[+] private def remove ( bucket: Int , prevEntry: Entry [ A ] , entry: Entry [ A ] ) : Unit

remove a single entry from a linked list in a given bucket

[+] private def removeStaleEntries ( ) : Unit

remove entries associated with elements that have been gc'ed

[+] private def resize ( ) : Unit

Double the size of the internal table

[+] override def size : Int
[+] override def toList ( ) : List [ A ]