search

goog.structs.LinkedMap<KEY, VALUE>

Provided By

Class for a LinkedMap datastructure, which combines O(1) map access for key/value pairs with a linked list for a consistent iteration order. Sample usage:

 var m = new LinkedMap();
 m.set('param1', 'A');
 m.set('param2', 'B');
 m.set('param3', 'C');
 alert(m.getKeys()); // param1, param2, param3

 var c = new LinkedMap(5, true);
 for (var i = 0; i < 10; i++) {
   c.set('entry' + i, false);
 }
 alert(c.getKeys()); // entry9, entry8, entry7, entry6, entry5

 c.set('entry5', true);
 c.set('entry1', false);
 alert(c.getKeys()); // entry1, entry5, entry9, entry8, entry7
 

new LinkedMap<KEY, VALUE>( opt_maxCount, opt_cache, opt_evictionCallback )

Parameters
opt_maxCountnumber=

The maximum number of objects to store in the LinkedMap. If unspecified or 0, there is no maximum.

opt_cacheboolean=

When set, the LinkedMap stores items in order from most recently used to least recently used, instead of insertion order.

opt_evictionCallbackfunction(string, (VALUE|null)): ?=

Called with the removed stringified key as the first argument and value as the second argument after the key was evicted from the LRU because the max count was reached.

Instance Methods

Instance Properties

Classes