Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
CPLRUDictionary: Difference between revisions - iPhone Development Wiki

CPLRUDictionary: Difference between revisions

From iPhone Development Wiki
(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 …')
 
m (Reordering)
 
Line 1: Line 1:
{{occlass|library=AppSupport.framework}}
[[CPLRUDictionary]] is a dictionary storing a limited set of data, with extra data filted out by last accessed time. LRU stands for Least Recently Used<ref name="tn">http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used</ref>.


[[CPLRUDictionary]] is a dictionary storing limited set of data, with extra data filted out by last accessed time. LRU stands for Least Recently Used [http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used].
<source lang="objc">
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.


<source lang="objc">
[dict release];
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];
</source>
</source>


== Header ==
== References ==
* http://github.com/kennytm/iphone-private-frameworks/blob/master/AppSupport/CPLRUDictionary.h
 
<references/>
 
== External links ==
 
{{IPFHeader|AppSupport}}

Latest revision as of 16:27, 26 October 2014

CPLRUDictionary is a dictionary storing a 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];

References

External links