The goog.ds.SortedNodeList Class

goog.ds.SortedNodeList
> goog.ds.BasicNodeList
> goog.ds.DataNodeList
> goog.ds.DataNode

goog.ds.SortedNodeList(compareFn, opt_nodes)

Node list implementation which maintains sort order during insertion and modification operations based on a comparison function. The SortedNodeList does not guarantee sort order will be maintained if the underlying data nodes are modified externally. Names that are reserved for system use and shouldn't be used for data node names: eval, toSource, toString, unwatch, valueOf, watch. Behavior is undefined if these names are used.

compareFn {Function}
Comparison function by which the node list is sorted. Should take 2 arguments to compare, and return a negative integer, zero, or a positive integer depending on whether the first argument is less than, equal to, or greater than the second.
opt_nodes {Array.<goog.ds.DataNode>=}
optional nodes to add to list; these are assumed to be in sorted order.

.add(node)

Add a node to the node list, maintaining sort order. If the node has a dataName, uses this for the key in the map.

node {goog.ds.DataNode}
The node to add.

.append(node)

Adds the given node to the end of the SortedNodeList. This should only be used when the caller can guarantee that the sort order will be maintained according to this SortedNodeList's compareFn (e.g. when initializing a new SortedNodeList from a list of nodes that has already been sorted).

node {goog.ds.DataNode}
The node to append.

.get(key)

Inherited from goog.ds.BasicNodeList .

Get a node by string key. Returns null if node doesn't exist.

key {string}
String lookup key.
returns {goog.ds.DataNode}
The node, or null if doesn't exist.

.getByIndex(index)

Inherited from goog.ds.BasicNodeList .

Get a node by index Returns null if the index is out of range

index {number}
The index of the node.
returns {goog.ds.DataNode}
The node, or null if doesn't exist.

.getChildNode(name, opt_canCreate)

Inherited from goog.ds.DataNode .

Gets a named child node of the current node

name {string}
The node name.
opt_canCreate {boolean=}
Whether to create a child node if it does not exist.
returns {goog.ds.DataNode}
The child node, or null if no node of this name exists.

.getChildNodeValue(name)

Inherited from goog.ds.DataNode .

Gets the value of a child node

name {string}
The node name.
returns {*}
The value of the node, or null if no value or the child node doesn't exist.

.getChildNodes(opt_selector)

Inherited from goog.ds.DataNode .

Gets all of the child nodes of the current node. Should return an empty DataNode list if no child nodes.

opt_selector {string=}
String selector to choose child nodes.
returns {goog.ds.DataNodeList}
The child nodes.

.getCount()

Inherited from goog.ds.BasicNodeList .

Gets the size of the node list

returns {number}
The size of the list.

.getDataName()

Inherited from goog.ds.DataNode .

Get the name of the node relative to the parent node

returns {string}
The name of the node.

.getDataPath()

Inherited from goog.ds.DataNode .

Gets the a qualified data path to this node

returns {string}
The data path.

.getLoadState()

Inherited from goog.ds.DataNode .

Gets the state of the backing data for this node

returns {goog.ds.LoadState}
The state.

.indexOf(name)

Inherited from goog.ds.BasicNodeList .

Get the index of a named node

name {string}
The name of the node to get the index of.
returns {number|undefined}
The index.

.isList()

Inherited from goog.ds.DataNode .

Whether the value of this node is a homogeneous list of data

returns {boolean}
True if a list.

.load()

Inherited from goog.ds.DataNode .

Load or reload the backing data for this node

.removeNode(name)

Inherited from goog.ds.BasicNodeList .

Removes a node in the list of a given name

name {string}
Name of the node.
returns {boolean}
True if node existed and was deleted.

.set(value)

Inherited from goog.ds.DataNode .

Set the value of the node

value {*}
The new value of the node.

.setChildNode(name, value)

Inherited from goog.ds.DataNode .

Sets a named child node of the current node.

name {string}
The node name.
value {Object}
The value to set, can be DataNode, object, property, or null. If value is null, removes the child node.
returns {Object}
The child node, if the node was set.

.setDataName(name)

Inherited from goog.ds.DataNode .

Set the name of the node relative to the parent node

name {string}
The name of the node.

.setNode(name, node)

Sets a node in the list of a given name, maintaining sort order.

name {string}
Name of the node.
node {goog.ds.DataNode}
The node.