ds.SortedNodeList Extends goog.ds.BasicNodeList
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.

Inheritance

Constructor

goog.ds.SortedNodeList(compareFnopt_nodes)

Parameters

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.

Instance Methods

Public Protected Private
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.
Arguments:
node : goog.ds.DataNode
The node to add.
code »
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).
Arguments:
node : goog.ds.DataNode
The node to append.
code »
setNode(namenode)
Sets a node in the list of a given name, maintaining sort order.
Arguments:
name : string
Name of the node.
node : goog.ds.DataNode
The node.
code »
add(node)
Add a node to the node list. If the node has a dataName, uses this for the key in the map. TODO(user) Remove function as well
Arguments:
node : goog.ds.DataNode
The node to add.
code »
get(key) goog.ds.DataNode
Get a node by string key. Returns null if node doesn't exist.
Arguments:
key : string
String lookup key.
Returns: goog.ds.DataNode  The node, or null if doesn't exist.
code »
getByIndex(index) goog.ds.DataNode
Get a node by index Returns null if the index is out of range
Arguments:
index : number
The index of the node.
Returns: goog.ds.DataNode  The node, or null if doesn't exist.
code »
getCount() number
Gets the size of the node list
Returns: number  The size of the list.
code »
indexOf(name) number | undefined
Get the index of a named node
Arguments:
name : string
The name of the node to get the index of.
Returns: number | undefined  The index.
code »
removeNode(name) boolean
Removes a node in the list of a given name
Arguments:
name : string
Name of the node.
Returns: boolean  True if node existed and was deleted.
code »
setNode(namenode)
Sets a node in the list of a given name
Arguments:
name : string
Name of the node.
node : goog.ds.DataNode
The node.
code »
add(node)
Add a node to the node list. If the node has a dataName, uses this for the key in the map.
Arguments:
node : goog.ds.DataNode
The node to add.
code »
get(key) *
Get a node by string key. Returns null if node doesn't exist.
Arguments:
key : string
String lookup key.
Returns: *  The node, or null if doesn't exist.
code »
getByIndex(index) goog.ds.DataNode
Get a node by index Returns null if the index is out of range
Arguments:
index : number
The index of the node.
Returns: goog.ds.DataNode  The node, or null if doesn't exist.
code »
getCount() number
Gets the size of the node list
Returns: number  The size of the list.
code »
removeNode(name) boolean
Removes a node in the list of a given name
Arguments:
name : string
Name of the node.
Returns: boolean  True if node existed and was deleted.
code »
setNode(namenode)
Sets a node in the list of a given name
Arguments:
name : string
Name of the node.
node : goog.ds.DataNode
The node.
code »
get(var_args) *
Get the value of the node
Arguments:
var_args : ?...
Do not check arity of arguments, because some subclasses require args.
Returns: *  The value of the node, or null if no value.
code »
getChildNode(nameopt_canCreate) goog.ds.DataNode
Gets a named child node of the current node
Arguments:
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.
code »
getChildNodeValue(name) *
Gets the value of a child node
Arguments:
name : string
The node name.
Returns: *  The value of the node, or null if no value or the child node doesn't exist.
code »
getChildNodes(opt_selector) !goog.ds.DataNodeList
Gets all of the child nodes of the current node. Should return an empty DataNode list if no child nodes.
Arguments:
opt_selector : string=
String selector to choose child nodes.
Returns: !goog.ds.DataNodeList  The child nodes.
code »
getDataName() string
Get the name of the node relative to the parent node
Returns: string  The name of the node.
code »
getDataPath() string
Gets the a qualified data path to this node
Returns: string  The data path.
code »
getLoadState() goog.ds.LoadState
Gets the state of the backing data for this node
Returns: goog.ds.LoadState  The state.
code »
isList() boolean
Whether the value of this node is a homogeneous list of data
Returns: boolean  True if a list.
code »
set(value)
Set the value of the node
Arguments:
value : *
The new value of the node.
code »
setChildNode(namevalue) Object
Sets a named child node of the current node.
Arguments:
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.
code »
setDataName(name)
Set the name of the node relative to the parent node
Arguments:
name : string
The name of the node.
code »

Instance Properties

compareFn_ :
No description.
Code »
constructor :
No description.
Code »
indexMap_ :
No description.
Code »
list_ :
No description.
Code »
map_ :
No description.
Code »
load :
Load or reload the backing data for this node
Code »

Static Properties

goog.ds.SortedNodeList.superClass_ :
No description.
Code »

Package ds

Package Reference