structs

Classes

goog.structs.AvlTree
Constructs an AVL-Tree, which uses the specified comparator to order its values. The values can be accessed efficiently in their sorted order since the tree enforces a O(logn) maximum height.
goog.structs.CircularBuffer
Class for CircularBuffer.
goog.structs.Collection
An interface for a collection of values.
goog.structs.Heap
Class for a Heap datastructure.
goog.structs.InversionMap
Maps ranges to values.
goog.structs.LinkedMap
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
goog.structs.Map
Class for Hash Map datastructure.
goog.structs.Node
A generic immutable node. This can be used in various collections that require a node object for its item (such as a heap).
goog.structs.Pool
A generic pool class. If min is greater than max, an error is thrown.
goog.structs.PriorityPool
A generic pool class. If max is greater than min, an error is thrown.
goog.structs.PriorityQueue
Class for Priority Queue datastructure.
goog.structs.QuadTree
Constructs a new quad tree.
goog.structs.Queue
Class for FIFO Queue data structure.
goog.structs.Set
A set that can contain both primitives and objects. Adding and removing elements is O(1). Primitives are treated as identical if they have the same type and convert to the same string. Objects are treated as identical only if they are references to the same object. WARNING: A goog.structs.Set can contain both 1 and (new Number(1)), because they are not the same. WARNING: Adding (new Number(1)) twice will yield two distinct elements, because they are two different objects. WARNING: Any object that is added to a goog.structs.Set will be modified! Because goog.getUid() is used to identify objects, every object in the set will be mutated.
goog.structs.SimplePool
A generic pool class. Simpler and more efficient than goog.structs.Pool because it doesn't maintain a list of objects that are in use. This class has constant overhead and doesn't create any additional objects as part of the pool management after construction time. IMPORTANT: If the objects being pooled are arrays or maps that can have unlimited number of properties, they need to be cleaned before being returned to the pool. Also note that actually allocates an array to clean the object passed to it, so simply using this function would defy the purpose of using the pool.
goog.structs.StringSet
Creates a set of strings.
goog.structs.TreeNode
Generic tree node data structure with arbitrary number of child nodes. It is possible to create a dynamic tree structure by overriding #getParent and #getChildren in a subclass. All other getters will automatically work.
goog.structs.Trie
Class for a Trie datastructure. Trie data structures are made out of trees of Trie classes.

Public Protected Private

Global Functions

goog.structs.clear(col)
Removes all the elements from the collection.
Arguments:
col : Object
The collection-like object.
code »
goog.structs.contains(colval) boolean
Whether the collection contains the given value. This is O(n) and uses equals (==) to test the existence.
Arguments:
col : Object
The collection-like object.
val : *
The value to check for.
Returns: boolean  True if the map contains the value.
code »
goog.structs.every(colfopt_obj) boolean
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 : S
The collection-like object.
f : function(this:T,?,?,S):boolean
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 : T=
The object to be used as the value of 'this' within f.
Returns: boolean  True if all key-value pairs pass the test.
code »
goog.structs.filter(colfopt_obj) !Object | !Array
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 : S
The collection-like object.
f : function(this:T,?,?,S):boolean
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 : T=
The object to be used as the value of 'this' within f.
Returns: !Object | !Array  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. NOTE: This will be deprecated soon! Please use a more specific method if possible, e.g. goog.array.forEach, goog.object.forEach, etc.
Arguments:
col : S
The collection-like object.
f : function(this:T,?,?,S):?
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 : T=
The object to be used as the value of 'this' within f.
code »
goog.structs.getCount(col) number
Returns the number of values in the collection-like object.
Arguments:
col : Object
The collection-like object.
Returns: number  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
The collection-like object.
Returns: !Array | undefined  The keys in the collection.
code »
goog.structs.getValues(col) !Array
Returns the values of the collection-like object.
Arguments:
col : Object
The collection-like object.
Returns: !Array  The values in the collection-like object.
code »
goog.structs.isEmpty(col) boolean
Whether the collection is empty.
Arguments:
col : Object
The collection-like object.
Returns: boolean  True if empty.
code »
goog.structs.map(colfopt_obj) !Object.<V> | !Array.<V>
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 : S
The collection-like object.
f : function(this:T,?,?,S):V
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 : T=
The object to be used as the value of 'this' within f.
Returns: !Object.<V> | !Array.<V>  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) boolean
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 : S
The collection-like object.
f : function(this:T,?,?,S):boolean
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 : T=
The object to be used as the value of 'this' within f.
Returns: boolean  True if any value passes the test.
code »

Global Properties

goog.structs.AvlTreeTest :
No description.
Code »
goog.structs.CircularBufferTest :
No description.
Code »
goog.structs.CollectionTest :
No description.
Code »
goog.structs.HeapTest :
No description.
Code »
goog.structs.InversionMapTest :
No description.
Code »
goog.structs.LinkedMapTest :
No description.
Code »
goog.structs.MapTest :
No description.
Code »
goog.structs.PoolTest :
No description.
Code »
goog.structs.PriorityPoolTest :
No description.
Code »
goog.structs.PriorityQueueTest :
No description.
Code »
goog.structs.QuadTreeTest :
No description.
Code »
goog.structs.QueueTest :
No description.
Code »
goog.structs.SetTest :
No description.
Code »
goog.structs.StringSetTest :
No description.
Code »
goog.structs.TreeNodeTest :
No description.
Code »
goog.structs.TrieTest :
No description.
Code »

Package structs

Package Reference