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)
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
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(KeyValuePairTKey, TValue)Overloaded.
Shortcut to test if any of the given items are contained in the specified object.
(Defined by CollectionExtensions.)
Public Extension MethodContainsAnyKeyValuePairTKey, TValue(IEqualityComparerKeyValuePairTKey, TValue, KeyValuePairTKey, TValue)Overloaded.
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(ActionKeyValuePairTKey, TValue)Overloaded.
Performs the specified action on each element of the collection.
(Defined by CollectionExtensions.)
Public Extension MethodForEachKeyValuePairTKey, TValue(ActionKeyValuePairTKey, TValue, Int32)Overloaded.
Performs the specified action on each element of the collection, providing also the index of the item.
(Defined by CollectionExtensions.)
Public Extension MethodIndexOfKeyValuePairTKey, TValue(KeyValuePairTKey, TValue)Overloaded.
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(KeyValuePairTKey, TValue, IEqualityComparerKeyValuePairTKey, TValue)Overloaded.
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