goog.structs.LinkedMap
Classgoog.structs.LinkedMap(opt_maxCount, opt_cache)
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
opt_maxCount
{number
=}
opt_cache
{boolean
=}
.clear()
Removes all entries in this object.
.contains(value)
Tests whether a provided value is currently in the LinkedMap. This does not affect item ordering in cache-style LinkedMaps.
value
{Object
}
boolean
}
.containsKey(key)
Tests whether a provided key is currently in the LinkedMap. This does not affect item ordering in cache-style LinkedMaps.
key
{string
}
boolean
}
.every(f, opt_obj)
Calls a function on each item in the LinkedMap and returns true only if every function call returns a true-like value.
f
{Function
}
opt_obj
{Object
=}
boolean
}
.forEach(f, opt_obj)
Calls a function on each item in the LinkedMap.
f
{Function
}
opt_obj
{Object
=}
.get(key, opt_val)
Retrieves the value for a given key. If this is a caching LinkedMap, the entry will become the most recently used.
key
{string
}
opt_val
{*=}
.getCount()
number
}
.getKeys()
Array
.<string
>}
.getValues()
Array
}
.isEmpty()
boolean
}
.map(f, opt_obj)
Calls a function on each item in the LinkedMap and returns the results of those calls in an array.
f
{!Function
}
opt_obj
{Object
=}
Array
}
.peek()
Returns the value of the first node without making any modifications.
.peekLast()
Returns the value of the last node without making any modifications.
.peekValue(key, opt_val)
Retrieves the value for a given key without updating the entry to be the most recently used.
key
{string
}
opt_val
{*=}
.pop()
Removes the last node from the list and returns its value.
.remove(key)
Removes a value from the LinkedMap based on its key.
key
{string
}
boolean
}
.removeNode(node)
[protected]Removes a node from the {@code LinkedMap}. It can be overridden to do further cleanup such as disposing of the node value.
node
{!goog.structs.LinkedMap.Node_
}
.set(key, value)
Sets a value for a given key. If this is a caching LinkedMap, this entry will become the most recently used.
key
{string
}
value
{*}
.setMaxCount(maxCount)
Sets the maximum number of entries allowed in this object, truncating any excess objects if necessary.
maxCount
{number
}
.shift()
Removes the first node from the list and returns its value.
.some(f, opt_obj)
Calls a function on each item in the LinkedMap and returns true if any of those function calls returns a true-like value.
f
{Function
}
opt_obj
{Object
=}
boolean
}