| FindNode | R Documentation |
Scans the entire sub-tree spanned by node and returns the first Node
having the name specified. This is mainly useful for trees whose name is unique.
If AreNamesUnique is FALSE, i.e. if there is more than one Node
called name in the tree, then it is undefined which one will be returned.
Also note that this method is not particularly fast. See examples for a faster way to
index large trees, if you need to do multiple searches. See Traverse if
you need to find multiple Nodes.
FindNode(node, name)
node |
The root |
name |
The name of the |
The first Node whose name matches, or NULL if no such Node is
found.
AreNamesUnique, Traverse
data(acme)
FindNode(acme, "Outsource")
#re-usable hashed index for multiple searches:
if(!AreNamesUnique(acme)) stop("Hashed index works for unique names only!")
trav <- Traverse(acme, "level")
names(trav) <- Get(trav, "name")
nameIndex <- as.environment(trav)
#you could also use hash from package hash instead!
#nameIndex <- hash(trav)
nameIndex$Outsource
nameIndex$IT
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.