EDLRUCache


Inherits From:
NSObject
Declared In:
EDLRUCache.h


Class Description

A simple Last-Recently-Used cache. When the cache is full, as defined by by its size, and an object is added, the object that has not been accessed for the longest time is automatically removed. Currently, only very basic operations are supported but implementing additions should be straightforward when requried.

This datastructure does not implement the copying and coding protocols as caches are usually required in the context of algorithms, rather than data storage.


Instance Variables

unsigned int size;
NSMutableDictionary *entries;
NSMutableDictionary *timestamps;

sizeAll instance variables are private.
entries
timestamps


Method Types

Creating caches
- initWithCacheSize:
Adding/removing objects
- addObject:withKey:
- objectWithKey:

Instance Methods

addObject:withKey:

- (void)addObject:(id)newObject withKey:(id)newKey

Adds an entry to the receiver, consisting of newKey and its corresponding value object newObject. For details on the operation please see the discussion in NSDictionary.


initWithCacheSize:

- (id)initWithCacheSize:(unsigned int)count

Initialises a newly allocated LRU cache to store count items.


objectWithKey:

- (id)objectWithKey:(id)aKey

Returns an entry's value given its key, or nil if no value is associated with aKey.


Version 2.0 Copyright ©2002. All Rights Reserved.