/* A definite node is constructed from a specified number of
children.  That number of nodes are popped from the stack and
made the children of the definite node.  Then the definite node
is pushed on to the stack.
7415
void closeNodeScope(Node n, int num) {
    mk = ((Integer)marks.pop()).intValue();
    while (num-- > 0) {
      Node c = popNode();
      c.jjtSetParent(n);
      n.jjtAddChild(c, num);
    }
    n.jjtClose();
    pushNode(n);
    node_created = true;
  }
928977
public void pushNode(Node node) {
        initNode(node);

        // Reset in stream
        inStream = null;

        synchronized (nodeStack) {

            // Clear popped stack
            poppedNodes.clear();

            // Check if fragment is in suppression mode
            if (suppress) {
                suppressedNodeStack.push(node);
                return;
            }

            if (nodeStack.isEmpty()) {
                if (log.isLoggable(Level.FINEST)) {
                    log.finest("Pushing top level node: " + node + " for txn: " + trace);
                }
                trace.getNodes().add(node);
            } else {
                Node parent = nodeStack.peek();

                if (parent instanceof ContainerNode) {
                    if (log.isLoggable(Level.FINEST)) {
                        log.finest("Add node: " + node + " to parent: " + parent + " in txn: " + trace);
                    }
                    ((ContainerNode) parent).getNodes().add(node);
                } else {
                    log.severe("Attempt to add node '" + node + "' under non-container node '" + parent + "'");
                }
            }
            nodeStack.push(node);
        }
    }
683510
function(newNode, refNode){
      var nodes = this.nodes;
      var pos = refNode ? nodes.indexOf(refNode) : -1;

      if (pos == -1)
      {
        nodes.push(newNode);
        this.last = newNode;
      }
      else
        nodes.splice(pos, 0, newNode);

      this.first = nodes[0];

      newNode.groupNode = this;

      this.emit_childNodesModified({ inserted: [newNode] });
    }
1262252
function Node(key, value) {
  this.key = key;
  this.value = value;
  this.degree = 0;
  this.parent = undefined;
  this.child = undefined;
  this.sibling = undefined;
}
1209562
private void stackStart(
    GBSNode     node)
  {
    _idx = 0;
    _cidx = 0;
    _state[_cidx] = 0;
    _node[_cidx]  = node;
    _bpidx = _cidx + 1;
    _maxIdx = _cidx;
  }
819802
public void addNode(N node)
    {
        if(!nodes.containsKey(node))
            nodes.put(node, new Pair<HashSet<N>, HashSet<N>>(new HashSet<N>(), new HashSet<N>()));
    }
757100
function(a, b) {
      for (var i = 0, node; node = b[i]; i++)
        a.push(node);
      return a;
    }
823067
public SharedTreeNode makeRootNode() {
    assert nodesArray.size() == 0;
    SharedTreeNode n = new SharedTreeNode(0, null, subgraphNumber, 0);
    n.setInclusiveNa(true);
    nodesArray.add(n);
    rootNode = n;
    return n;
  }
985389
private Node<K, V> cutChildren(Node<K, V> n) {
        Node<K, V> child = n.o_c;
        n.o_c = null;
        if (child != null) {
            child.o_s = null;
        }
        return child;
    }
697428
function instantiateChildren(nestedChildNodes, transaction, context, selfDebugID) // 0 in production and for roots
  {
    if (nestedChildNodes == null) {
      return null;
    }
    var childInstances = {};

    if (false) {
      traverseAllChildren(nestedChildNodes, function (childInsts, child, name) {
        return instantiateChild(childInsts, child, name, selfDebugID);
      }, childInstances);
    } else {
      traverseAllChildren(nestedChildNodes, instantiateChild, childInstances);
    }
    return childInstances;
  }
830298
function(node) {
         var newNode = function(data, next) {
             var that = {};
             that.getData = function() {
                 return data;
             };
             that.getNext = function() {
                 return next;
             };
             return that;
         };
         var top = node || null;
         var that = {};

         that.__push_internal__ = function(data) {
             return newStack(newNode(data, top));
         };

         that.__peek__ = function() {
             return top && top.getData();
         };

         that.__pop_internal__ = function() {
             return top && newStack(top.getNext());
         };

         that.__forEach__ = function(f) {
             var i = top;
             var s = 0;
             while (i !== null) {
                 f(i.getData(), s);
                 s = s +1;
                 i = i.getNext();
             }
         };
         that.__map__ = function(f) {
             var i = top;
             var result = [];
             while (i !== null) {
                 result.push(f(i.getData()));
                 i = i.getNext();
             }
             return result;
         };

         that.__length__ = function() {
             var count = 0;
             that.__forEach__(function() { count = count + 1;});
             return count;
         };

         return that;
     }
266043
function() {
            var depth = this.getDepth(),
                that = this,
                index = 0,
                nodes, len, n, child;

            function addChildren(children) {
                nodes = [];
                len = children.length;
                for(n = 0; n < len; n++) {
                    child = children[n];
                    index++;

                    if(child.nodeType !== SHAPE) {
                        nodes = nodes.concat(child.getChildren().toArray());
                    }

                    if(child._id === that._id) {
                        n = len;
                    }
                }

                if(nodes.length > 0 && nodes[0].getDepth() <= depth) {
                    addChildren(nodes);
                }
            }
            if(that.nodeType !== UPPER_STAGE) {
                addChildren(that.getStage().getChildren());
            }

            return index;
        }
33240
function referenceParentNode () {
            // If nodeName is an empty string, then reference the parent of the root child.
            if (isEmptyString(nodeName)) {
                nodeName = this.$parentName;

                // Even though super might be invoked in different constructors,
                // the same instance will always be referenced. rootName is used
                // to know if the chain has been broken.
                rootName = this.$name;

                // Prevent instance from having parent properties applied more than once.
                if (this.$applied) {
                    throwError(`Cannot invoke super more than once for ${this.$name} instance.`, 'SUPER');
                } else {
                    descriptor.value = true;

                    Object.defineProperty(this, '$applied', descriptor);
                }

            // Otherwise just move to next parent.
            } else {
                // Error out if chain is broken.
                if (this.$name !== rootName) {
                    throwError(`Chain started by ${rootName} instance is being broken by ${this.$name} instance.`, 'SUPER');
                }

                nodeName = CLASS[nodeName].prototype.$parentName;
            }
        }
1278504
function (node) {
            var first = node, length = 1;
            if (node.nodeType == 11) {
                first = node.firstChild;
                length = node.childNodes.length;
            }
            this.trimBoundary(true);
            var start = this.startContainer,
                offset = this.startOffset;
            var nextNode = start.childNodes[ offset ];
            if (nextNode) {
                start.insertBefore(node, nextNode);
            } else {
                start.appendChild(node);
            }
            if (first.parentNode === this.endContainer) {
                this.endOffset = this.endOffset + length;
            }
            return this.setStartBefore(first);
        }
399095
function(current, position) {

      var x, newNode, node, firstChild;

      // create a new node
      newNode = current.cloneNode(true);

      // create new node in mirror
      if (position == 'before') {

        // insert element
        current.parentNode.insertBefore(newNode, current);

      }

      // re-init sortable
      hashedit.setupSortable();

      return newNode;

    }
1033064
function () {
                var children = [],
                    addedDescriptors = [],
                    i, child;

                if (this.$defaultContentName && this.$defaultTemplateName) {
                    throw "both $defaultContentName and $defaultTemplateName are defined";
                }

                var desc;

                function addChildren(childrenFromDescriptor, fromDescriptor) {

                    // don't add children with the same descriptor twice
                    for (var j = 0; j < childrenFromDescriptor.length; j++) {
                        child = childrenFromDescriptor[j];
                        child.$fromDescriptor = fromDescriptor;

                        if (child.$createdByTemplate || _.indexOf(addedDescriptors, child.$descriptor) === -1) {
                            children.push(child);
                            if (child.$descriptor) {
                                addedDescriptors.push(child.$descriptor);
                            }
                        }
                    }
                }

                for (var d = 0; d < this.$internalDescriptors.length; d++) {
                    desc = this.$internalDescriptors[d];
                    addChildren(this._getChildrenFromDescriptor(desc, this, null, this), "intern");
                }

                var externalDescriptorChildren;

                if (this.$defaultTemplateName) {
                    var templateBlock;

                    // go through all children from the external descriptor
                    // and check if a template block with the name $defaultTemplateName

                    for (i = 0; i < this.$descriptor.childNodes.length; i++) {
                        var node = this.$descriptor.childNodes[i];

                        if (node.nodeType === 1 &&
                            node.getAttribute("name") === this.$defaultTemplateName &&
                            this.$stage.$applicationContext.getFqClassName(node.namespaceURI, this._localNameFromDomNode(node), true) === "js/core/Template") {

                            templateBlock = node;
                            break;
                        }
                    }

                    if (!templateBlock && this.$descriptor) {
                        templateBlock = this.createComponent(Component.Template, {
                            name: this.$defaultTemplateName
                        }, this.$descriptor);

                        externalDescriptorChildren = [templateBlock];
                    }

                }

                externalDescriptorChildren = externalDescriptorChildren || this._getChildrenFromDescriptor(this.$descriptor);


                if (this.$defaultContentName && this.$descriptor) {
                    // check if content block is already defined
                    var contentBlock,
                        internAndExternalChildren = children.concat(externalDescriptorChildren);


                    for (i = 0; i < internAndExternalChildren.length; i++) {
                        child = internAndExternalChildren[i];

                        if (child instanceof Component.Content && child.$.name === this.$defaultContentName) {
                            // content block already defined
                            contentBlock = child;
                            break;
                        }
                    }

                    if (!contentBlock) {
                        // create a content block and move all children in a js.core.Content Block
                        contentBlock = this.createComponent(Component.Content, {
                            name: this.$defaultContentName
                        });

                        // add all children to content block
                        for (i = 0; i < externalDescriptorChildren.length; i++) {
                            contentBlock.addChild(externalDescriptorChildren[i]);
                        }

                        externalDescriptorChildren = [contentBlock];
                    }

                }

                addChildren(externalDescriptorChildren, "external");

                var extraChildren = this.createChildren();
                if (extraChildren) {
                    addChildren(extraChildren, "extra");
                }

                this._initializeChildren(children);

                this._childrenInitialized();

                this._initializeXamlEventAttributes(this.$xamlDefaults, this);
                this._initializeXamlEventAttributes(this.$xamlAttributes, this.$rootScope);
            }
861355
def n(type, children, source_map)
      Node.new(type, children, location: source_map)
    end