Click or drag to resize

AutoWeakIndexerTKey, TValue Class

A thread safe, DictionaryTKey, TValue like implementation that populates it's content on demand, i.e. calling indexer[key] will never return null. The cache has only weak references to the values, so the values may come and go.
Inheritance Hierarchy
SystemObject
  TomsToolbox.EssentialsAutoWeakIndexerTKey, TValue

Namespace: TomsToolbox.Essentials
Assembly: TomsToolbox.Essentials (in TomsToolbox.Essentials.dll) Version: 2.21.0+44d18b541fc9419ec3c549350a832394661b2a4d
XMLNS for XAML: Not mapped to an xmlns.
Syntax
public sealed class AutoWeakIndexer<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, 
	IEnumerable
where TValue : class

Type Parameters

TKey
The type of the key.
TValue
The type of the value.

The AutoWeakIndexerTKey, TValue type exposes the following members.

Constructors
 NameDescription
Public methodAutoWeakIndexerTKey, TValue Initializes a new instance of the AutoWeakIndexerTKey, TValue class.
Top
Properties
 NameDescription
Public propertyComparer Gets the IEqualityComparerT that is used to determine equality of keys for the dictionary.
Public propertyItem Gets the value associated with the specified key.
Public propertyKeys Gets a collection containing the keys in the AutoWeakIndexerTKey, TValue.
Public propertyValues Gets a collection containing the values in the AutoWeakIndexerTKey, TValue.
Top
Methods
 NameDescription
Public methodClear Removes all keys and values from the AutoWeakIndexerTKey, TValue.
Public methodContainsKey Determines whether the AutoWeakIndexerTKey, TValue contains the specified key.
Public methodGetEnumerator Returns an enumerator that iterates through the items of the AutoWeakIndexerTKey, TValue.
Public methodTryGetValue Gets the value associated with the specified key.
Top
Extension Methods
 NameDescription
Public Extension MethodCombineFlagsKeyValuePairTKey, TValue Combines the flags into a single Enum.
(Defined by EnumExtensions)
Public Extension MethodContainsAnyKeyValuePairTKey, TValue Shortcut to test if any of the given items are contained in the specified object.
(Defined by CollectionExtensions)
Public Extension MethodContainsAnyKeyValuePairTKey, TValue Shortcut to test if any of the given items are contained in the specified object.
(Defined by CollectionExtensions)
Public Extension MethodFindIndexKeyValuePairTKey, TValue Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire IEnumerableT.
(Defined by CollectionExtensions)
Public Extension MethodForEachKeyValuePairTKey, TValue Performs the specified action on each element of the collection.
(Defined by CollectionExtensions)
Public Extension MethodForEachKeyValuePairTKey, TValue Performs the specified action on each element of the collection, providing also the index of the item.
(Defined by CollectionExtensions)
Public Extension MethodIndexOfKeyValuePairTKey, TValue Searches for the specified object and returns the zero-based index of the first occurrence within all items.
(Defined by CollectionExtensions)
Public Extension MethodIndexOfKeyValuePairTKey, TValue Searches for the specified object and returns the zero-based index of the first occurrence within all items.
(Defined by CollectionExtensions)
Public Extension MethodObservableCastTTarget Returns an observable collection of objects of type TTarget that mirrors the source collection.
(Defined by ObservableExtensions)
Public Extension MethodSafeCastT Performs a cast from object to T, avoiding possible null violations if T is a value type.
(Defined by ObjectExtensions)
Top
Remarks
This implementation is thread safe; the draw back is that generating new items is slow, so this type is not suitable for caching a large amount of items.
See Also