Ember.Map Class
A Map stores values indexed by keys. Unlike JavaScript's default Objects, the keys of a Map can be any JavaScript object.
Internally, a Map has two data structures:
keys
: an OrderedSet of all of the existing keysvalues
: a JavaScript Object indexed by theEmber.guidFor(key)
When a key/value pair is added for the first time, we
add the key to the keys
OrderedSet, and create or
replace an entry in values
. When an entry is deleted,
we delete its entry in keys
and values
.
Constructor
Ember.Map
()
private
Methods
clear
()
private
create
()
private
static
delete
-
key
Removes a value from the map for an associated key.
Parameters:
-
key
Returns:
true if an item was removed, false otherwise
forEach
-
callback
-
self
Iterate over all the keys and values. Calls the function once for each key, passing in value, key, and the map being iterated over, in that order.
The keys are guaranteed to be iterated over in insertion order.
Parameters:
-
callback
Function -
self
if passed, the
this
value inside the callback. By default,this
is the map.
get
-
key
Retrieve the value associated with a given key.
Parameters:
-
key
Returns:
the value associated with the key, or undefined
has
-
key
Check whether a key is present.
Parameters:
-
key
Returns:
true if the item was present, false otherwise
Properties
size
Number
private
This property will change as the number of objects in the map changes.
Default: 0