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

A dictionary with weak keys. More...

Source file:
Inheritance diagram for Loyc.Collections.WeakKeyDictionary< TKey, TValue >:
Loyc.Collections.Impl.DictionaryBase< TKey, TValue > Loyc.Collections.IDictionaryAndReadOnly< TKey, TValue >


A dictionary with weak keys.

Original source: datavault project. License: Apache License 2.0

Type Constraints
TKey :class 


override int Count [get]
 Number of items in the collection. More...
- Properties inherited from Loyc.Collections.Impl.DictionaryBase< TKey, TValue >
abstract int Count [get]
bool IsReadOnly [get]
ICollection< TKey > Keys [get]
ICollection< TValue > Values [get]
TValue this[TKey key] [get, set]

Public Member Functions

 WeakKeyDictionary (int capacity)
 WeakKeyDictionary (IEqualityComparer< TKey > comparer)
 WeakKeyDictionary (int capacity, IEqualityComparer< TKey > comparer)
override void Add (TKey key, TValue value)
override bool ContainsKey (TKey key)
override bool Remove (TKey key)
override bool TryGetValue (TKey key, out TValue value)
override void Clear ()
override IEnumerator< KeyValuePair< TKey, TValue > > GetEnumerator ()
void RemoveCollectedEntries ()
- Public Member Functions inherited from Loyc.Collections.Impl.DictionaryBase< TKey, TValue >
void Add (KeyValuePair< TKey, TValue > item)
bool Contains (KeyValuePair< TKey, TValue > item)
void CopyTo (KeyValuePair< TKey, TValue >[] array, int arrayIndex)
bool Remove (KeyValuePair< TKey, TValue > item)

Protected Member Functions

override void SetValue (TKey key, TValue value)
 Implementation of the setter for this[]. More...

Member Function Documentation

◆ SetValue()

override void Loyc.Collections.WeakKeyDictionary< TKey, TValue >.SetValue ( TKey  key,
TValue  value 

Implementation of the setter for this[].

The setter alone (without the getter) is not allowed to be virtual in C# so a separate method is required.

Implements Loyc.Collections.Impl.DictionaryBase< TKey, TValue >.

Property Documentation

◆ Count

override int Loyc.Collections.WeakKeyDictionary< TKey, TValue >.Count

Number of items in the collection.

WARNING: The count returned here may include entries for which key value objects have already been garbage collected. Call RemoveCollectedEntries to weed out collected entries and update the count accordingly.