Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
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< K, V > Loyc.Collections.IIndexed< in K, out V > Loyc.Collections.ICollectionAndReadOnly< T >

Remarks

A dictionary with weak keys.

Original source: datavault project. License: Apache License 2.0

Type Constraints
TKey :class 

Properties

override int Count [get]
 Number of items in the collection. More...
 
- Properties inherited from Loyc.Collections.Impl.DictionaryBase< TKey, TValue >
abstract int Count [get]
 
ICollection< TKey > Keys [get]
 
ICollection< TValue > Values [get]
 
TValue this[TKey key] [get, set]
 
- Properties inherited from Loyc.Collections.IIndexed< in K, out V >
this[K key] [get]
 Gets the value associated with the specified key. More...
 

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, [MaybeNullWhen(false)] 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 >
TValue TryGet (TKey key, [MaybeNullWhen(false)] out bool fail)
 
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...
 

Additional Inherited Members

- Public fields inherited from Loyc.Collections.Impl.DictionaryBase< TKey, TValue >
bool IsReadOnly => false
 
bool IsEmpty => Count != 0
 

Member Function Documentation

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

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

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

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.