You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
14 KiB
38 lines
14 KiB
<!DOCTYPE html><meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>goog.structs</title><link href="dossier.css" rel="stylesheet" type="text/css"><div id="main-wrapper"><input type="checkbox" id="sidenav-toggle" /><main><header><h1>Namespace goog.structs</h1><a class="source" href="source/lib/goog/structs/structs.js.src.html#l26">code »</a></header><section></section><section><h2>Classes</h2><div class="type-summary"><table><tbody><tr><td><dl><dt><a href="class_goog_structs_Map.html">goog.structs.Map</a><dd>Class for Hash Map datastructure.</dl></table></div></section><div id="visibility-controls"><b>Show:</b><label for="show-public"><span><input type="checkbox" id="show-public" checked/></span>Public</label><label for="show-protected"><span><input type="checkbox" id="show-protected"/></span>Protected</label><label for="show-private"><span><input type="checkbox" id="show-private"/></span>Private</label></div><section id="static-functions"><h2>Global Functions</h2><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/structs/structs.js.src.html#l148">code »</a><span class="member"><a name="goog.structs.clear">goog.structs.clear</a> <span class="args">( col )</span></span></div><p>Removes all the elements from the collection.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>col: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>The collection-like object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/structs/structs.js.src.html#l110">code »</a><span class="member"><a name="goog.structs.contains">goog.structs.contains</a> <span class="args">( col, val )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Whether the collection contains the given value. This is O(n) and uses
|
|
equals (==) to test the existence.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>col: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>The collection-like object.<dt>val: <code class="type">*</code><dd>The value to check for.</dl><tr><th>Returns<tr><td><dl>True if the map contains the value.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/structs/structs.js.src.html#l338">code »</a><code class="type"><T, S></code> <span class="member"><a name="goog.structs.every">goog.structs.every</a> <span class="args">( col, f, opt_obj )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>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.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>col: <code class="type">S</code><dd>The collection-like object.<dt>f: <code class="type">function(this: T, ?, ?, S): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code><dd>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.<dt>opt_obj: <code class="type">T=</code><dd>The object to be used as the value of 'this'
|
|
within <code >f</code>.</dl><tr><th>Returns<tr><td><dl>True if all key-value pairs pass the test.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/structs/structs.js.src.html#l210">code »</a><code class="type"><T, S></code> <span class="member"><a name="goog.structs.filter">goog.structs.filter</a> <span class="args">( col, f, opt_obj )</span> ⇒ <code class="type">(!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>|!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a>)</code></span></div><p>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).</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>col: <code class="type">S</code><dd>The collection-like object.<dt>f: <code class="type">function(this: T, ?, ?, S): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code><dd>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.<dt>opt_obj: <code class="type">T=</code><dd>The object to be used as the value of 'this'
|
|
within <code >f</code>.</dl><tr><th>Returns<tr><td><dl>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.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/structs/structs.js.src.html#l176">code »</a><code class="type"><T, S></code> <span class="member"><a name="goog.structs.forEach">goog.structs.forEach</a> <span class="args">( col, f, opt_obj )</span></span></div><p>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.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>col: <code class="type">S</code><dd>The collection-like object.<dt>f: <code class="type">function(this: T, ?, ?, S): ?</code><dd>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.<dt>opt_obj: <code class="type">T=</code><dd>The object to be used as the value of 'this'
|
|
within <code >f</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/structs/structs.js.src.html#l41">code »</a><span class="member"><a name="goog.structs.getCount">goog.structs.getCount</a> <span class="args">( col )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Returns the number of values in the collection-like object.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>col: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>The collection-like object.</dl><tr><th>Returns<tr><td><dl>The number of values in the collection-like object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/structs/structs.js.src.html#l82">code »</a><span class="member"><a name="goog.structs.getKeys">goog.structs.getKeys</a> <span class="args">( col )</span> ⇒ <code class="type">(!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined">undefined</a>)</code></span></div><p>Returns the keys of the collection. Some collections have no notion of
|
|
keys/indexes and this function will return undefined in those cases.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>col: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>The collection-like object.</dl><tr><th>Returns<tr><td><dl>The keys in the collection.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/structs/structs.js.src.html#l57">code »</a><span class="member"><a name="goog.structs.getValues">goog.structs.getValues</a> <span class="args">( col )</span> ⇒ <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code></span></div><p>Returns the values of the collection-like object.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>col: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>The collection-like object.</dl><tr><th>Returns<tr><td><dl>The values in the collection-like object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/structs/structs.js.src.html#l129">code »</a><span class="member"><a name="goog.structs.isEmpty">goog.structs.isEmpty</a> <span class="args">( col )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Whether the collection is empty.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>col: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>The collection-like object.</dl><tr><th>Returns<tr><td><dl>True if empty.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/structs/structs.js.src.html#l260">code »</a><code class="type"><T, S, V></code> <span class="member"><a name="goog.structs.map">goog.structs.map</a> <span class="args">( col, f, opt_obj )</span> ⇒ <code class="type">(!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>.<V>|!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a>.<V>)</code></span></div><p>Calls a function for every value in the collection and adds the result into a
|
|
new collection (defaults to creating a new Array).</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>col: <code class="type">S</code><dd>The collection-like object.<dt>f: <code class="type">function(this: T, ?, ?, S): V</code><dd>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.<dt>opt_obj: <code class="type">T=</code><dd>The object to be used as the value of 'this'
|
|
within <code >f</code>.</dl><tr><th>Returns<tr><td><dl>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.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/structs/structs.js.src.html#l304">code »</a><code class="type"><T, S></code> <span class="member"><a name="goog.structs.some">goog.structs.some</a> <span class="args">( col, f, opt_obj )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>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.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>col: <code class="type">S</code><dd>The collection-like object.<dt>f: <code class="type">function(this: T, ?, ?, S): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code><dd>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.<dt>opt_obj: <code class="type">T=</code><dd>The object to be used as the value of 'this'
|
|
within <code >f</code>.</dl><tr><th>Returns<tr><td><dl>True if any value passes the test.</dl></table></div></details></div></div></section></main><nav id="topnav"><div><div id="menubutton"><label for="sidenav-toggle">Menu</label></div><form id="searchbox"><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></nav><nav id="sidenav"><input type="checkbox" id="sidenav-types-ctrl" /><input type="checkbox" id="sidenav-files-ctrl" /><input type="checkbox" id="sidenav-modules-ctrl" /><a id="sidenav-overview"><div><h4>Overview</h4></div></a><div id="sidenav-types"><label for="sidenav-types-ctrl"><h4>Types</h4></label><i>No data</i></div><div id="sidenav-modules"><label for="sidenav-modules-ctrl"><h4>Modules</h4></label><i>No data</i></div><div id="sidenav-files"><label for="sidenav-files-ctrl"><h4>Files</h4></label><i>No data</i></div><a href="license.html"><div><h4>License</h4></div></a></nav><div id="push-footer"></div></div><footer><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></footer><script src="types.js"></script><script src="dossier.js"></script> |