structs.js
Generics method for collection-like classes and objects. This file contains functions to work with collections. It supports using Map, Set, Array and Object and other classes that implement collection-like methods.

File Location

structs/structs.js


Public Protected Private

Global Functions

goog.structs.clear(col)
Removes all the elements from the collection.
Arguments:
col :
(Object | null)
The collection-like object.
code »
goog.structs.contains(colval)
Whether the collection contains the given value. This is O(n) and uses equals (==) to test the existence.
Arguments:
col :
(Object | null)
The collection-like object.
val :
*
The value to check for.
Returns:   True if the map contains the value.
code »
goog.structs.every(colfopt_obj)
Calls f for each value in a collection. If all calls return true this return true this returns true. If any returns false this returns false at this point and does not continue to check the remaining values.
Arguments:
col :
(Object | null)
The collection-like object.
f :
(Function | null)
The function to call for every value. This function takes 3 arguments (the value, the key or undefined if the collection has no notion of keys, and the collection) and should return a Boolean.
opt_obj :
(Object | null | undefined)
The object to be used as the value of 'this' within f.
Returns:   True if all key-value pairs pass the test.
code »
goog.structs.filter(colfopt_obj)
Calls a function for every value in the collection. When a call returns true, adds the value to a new collection (Array is returned by default).
Arguments:
col :
(Object | null)
The collection-like object.
f :
(Function | null)
The function to call for every value. This function takes 3 arguments (the value, the key or undefined if the collection has no notion of keys, and the collection) and should return a Boolean. If the return value is true the value is added to the result collection. If it is false the value is not included.
opt_obj :
(Object | null | undefined)
The object to be used as the value of 'this' within f.
Returns:   A new collection where the passed values are present. If col is a key-less collection an array is returned. If col has keys and values a plain old JS object is returned.
code »
goog.structs.forEach(colfopt_obj)
Calls a function for each value in a collection. The function takes three arguments; the value, the key and the collection.
Arguments:
col :
(Object | null)
The collection-like object.
f :
(Function | null)
The function to call for every value. This function takes 3 arguments (the value, the key or undefined if the collection has no notion of keys, and the collection) and the return value is irrelevant.
opt_obj :
(Object | null | undefined)
The object to be used as the value of 'this' within f.
code »
goog.structs.getCount(col)
Returns the number of values in the collection-like object.
Arguments:
col :
(Object | null)
The collection-like object.
Returns:   The number of values in the collection-like object.
code »
goog.structs.getKeys(col)
(Array | undefined)
Returns the keys of the collection. Some collections have no notion of keys/indexes and this function will return undefined in those cases.
Arguments:
col :
(Object | null)
The collection-like object.
Returns: 
(Array | undefined)
  The keys in the collection.
code »
goog.structs.getValues(col)
Returns the values of the collection-like object.
Arguments:
col :
(Object | null)
The collection-like object.
Returns:   The values in the collection-like object.
code »
goog.structs.isEmpty(col)
Whether the collection is empty.
Arguments:
col :
(Object | null)
The collection-like object.
Returns:   True if empty.
code »
goog.structs.map(colfopt_obj)
Calls a function for every value in the collection and adds the result into a new collection (defaults to creating a new Array).
Arguments:
col :
(Object | null)
The collection-like object.
f :
(Function | null)
The function to call for every value. This function takes 3 arguments (the value, the key or undefined if the collection has no notion of keys, and the collection) and should return something. The result will be used as the value in the new collection.
opt_obj :
(Object | null | undefined)
The object to be used as the value of 'this' within f.
Returns:   A new collection with the new values. If col is a key-less collection an array is returned. If col has keys and values a plain old JS object is returned.
code »
goog.structs.some(colfopt_obj)
Calls f for each value in a collection. If any call returns true this returns true (without checking the rest). If all returns false this returns false.
Arguments:
col :
(Object | null | string)
The collection-like object.
f :
(Function | null)
The function to call for every value. This function takes 3 arguments (the value, the key or undefined if the collection has no notion of keys, and the collection) and should return a Boolean.
opt_obj :
(Object | null | undefined)
The object to be used as the value of 'this' within f.
Returns:   True if any value passes the test.
code »

Directory structs

File Reference