Enhanced C#
Language of your choice: library documentation
Properties | Public Member Functions | Protected Member Functions | List of all members
Loyc.Collections.WeakValueDictionary< K, V > Class Template Reference

A dictionary in which the values are weak. When a value has been garbage- collected, the dictionary acts as if the key is not present (except the Remove() method, which saves time by not checking whether the value is dead.) More...


Source file:
Inheritance diagram for Loyc.Collections.WeakValueDictionary< K, V >:
Loyc.Collections.Impl.BaseDictionary< K, V >

Remarks

A dictionary in which the values are weak. When a value has been garbage- collected, the dictionary acts as if the key is not present (except the Remove() method, which saves time by not checking whether the value is dead.)

This is implemented on top of a standard Dictionary. In order to allow the dictionary to be read safely while it is being enumerated, cleanup operations (to remove entries whose value has been garbage-collected) do not occur automatically during read operations. You can allow cleanups by calling AutoCleanup().

Type Constraints
V :class 

Properties

override int Count [get]
 Returns the number of dictionary entries. This value may be greater than the number of elements that are still alive. More...
 
- Properties inherited from Loyc.Collections.Impl.BaseDictionary< K, V >
abstract int Count [get]
 
bool IsReadOnly [get]
 
ICollection< TKey > Keys [get]
 
ICollection< TValue > Values [get]
 
TValue this[TKey key] [get, set]
 

Public Member Functions

bool AutoCleanup ()
 Periodically removes entries with garbage-collected values from the dictionary More...
 
void Cleanup ()
 Removes entries with garbage-collected values from the dictionary. More...
 
override void Clear ()
 
override void Add (K key, V value)
 
override bool ContainsKey (K key)
 
override bool Remove (K key)
 
override bool TryGetValue (K key, out V value)
 
override IEnumerator< KeyValuePair< K, V > > GetEnumerator ()
 
- Public Member Functions inherited from Loyc.Collections.Impl.BaseDictionary< K, V >
abstract void Add (TKey key, TValue value)
 
void Add (KeyValuePair< TKey, TValue > item)
 
abstract bool ContainsKey (TKey key)
 
abstract bool Remove (TKey key)
 
bool Remove (KeyValuePair< TKey, TValue > item)
 
abstract bool TryGetValue (TKey key, out TValue value)
 
bool Contains (KeyValuePair< TKey, TValue > item)
 
void CopyTo (KeyValuePair< TKey, TValue >[] array, int arrayIndex)
 

Protected Member Functions

override void SetValue (K key, V value)
 
- Protected Member Functions inherited from Loyc.Collections.Impl.BaseDictionary< K, V >
abstract void SetValue (TKey key, TValue value)
 

Member Function Documentation

bool Loyc.Collections.WeakValueDictionary< K, V >.AutoCleanup ( )
inline

Periodically removes entries with garbage-collected values from the dictionary

Referenced by Loyc.SymbolPool< SymbolE >.GetIfExists().

void Loyc.Collections.WeakValueDictionary< K, V >.Cleanup ( )
inline

Removes entries with garbage-collected values from the dictionary.

Property Documentation

override int Loyc.Collections.WeakValueDictionary< K, V >.Count
get

Returns the number of dictionary entries. This value may be greater than the number of elements that are still alive.