CPLRUDictionary

From iPhone Development Wiki
Revision as of 17:01, 21 September 2009 by KennyTM~ (talk | contribs) (Created page with '{{occlass|library=AppSupport.framework}} CPLRUDictionary is a dictionary storing limited set of data, with extra data filted out by last accessed time. LRU stands for Least …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


CPLRUDictionary is a dictionary storing limited set of data, with extra data filted out by last accessed time. LRU stands for Least Recently Used [1].

 CPLRUDictionary* dict = [[CPLRUDictionary alloc] initWithMaximumCapacity:4];
 
 [dict setObject:@"1" forKey:@"first"];
 [dict setObject:@"2" forKey:@"second"];
 [dict setObject:@"3" forKey:@"third"];
 [dict setObject:@"4" forKey:@"fourth"];
 [dict objectForKey:@"first"];	// Bump "first" as most recently used.
 [dict setObject:@"5" forKey:@"fifth"];
 [dict setObject:@"6" forKey:@"sixth"]; 
 
 NSLog(@"%@", [dict allKeys]);	// Should have "first", "fourth", "fifth" and "sixth" in any order.
 
 [dict release];

Header