0

I'm creating a cache class that utilises .NET's dictionary (class Cache<K, V> : Dictionary<K, V>) which only holds a number of classes in the dictionary at any one time. When new items are added old ones are deleted if the cache gets too big.

I have done Add, Remove and Clear but would like the cache to update an item such that the cache knows it's not that old any more if someone uses the dictionary's array lookup [] to change the class the key points to.

Is it event possible?

4

1 に答える 1

4

から派生しないでくださいDictionary<TKey, TValue>。代わりに、キャッシュをバックアップするために使用されるへIDictionary<TKey, TValue>の参照を使用して、クラスに実装します。Dictionary<TKey, TValue>つまり、継承の代わりに構成を使用します。

于 2012-04-11T10:26:41.967 に答える