Move all JS nodes from the head to the body.
196945
public void moveScriptElementsToBody ()
  {
    // Move all JS from head to body
    final ICommonsList <IHCNode> aJSNodes = new CommonsArrayList <> ();
    m_aHead.getAllAndRemoveAllJSNodes (aJSNodes);

    // Find index of first script in body
    int nFirstScriptIndex = 0;
    if (m_aBody.hasChildren ())
      for (final IHCNode aChild : m_aBody.getAllChildren ())
      {
        if (aChild instanceof IHCScript <?>)
        {
          // Check if this is a special inline script to be emitted before files
          final boolean bIsInlineBeforeFiles = (aChild instanceof IHCScriptInline <?>) &&
                                               !((IHCScriptInline <?>) aChild).isEmitAfterFiles ();
          if (!bIsInlineBeforeFiles)
          {
            // Remember index to insert before
            break;
          }
        }
        nFirstScriptIndex++;
      }

    m_aBody.addChildrenAt (nFirstScriptIndex, aJSNodes);
  }
177726
def walk(self, head=None):
        """"""
        head = head or self._root_node

        queue = []
        queue.insert(0, head)

        while queue:
            node = queue.pop()

            yield node.num, node.previous, node.siblings

            for child in node.siblings:
                if child in self._graph:
                    queue.insert(0, self._graph[child])
885805
function endNode() {
            if (parent.children) {
                mergeChildren(parent.children);
                sortChildren(parent.children);
            }
            parent = parentsStack.pop();
        }
349285
def add_jsfile_head(self, src: str) -> None:
        """"""
        self.head.appendChild(Script(src=src))
912900
function moveWebKitSelection() {
        function eventHandler(e) {
          var key = e.keyCode;

          function handle(upBool, sourceNode) {
            var siblingDirection = upBool ? 'previousSibling' : 'nextSibling';
            var currentRow = editor.dom.getParent(sourceNode, 'tr');
            var siblingRow = currentRow[siblingDirection];

            if (siblingRow) {
              moveCursorToRow(editor, sourceNode, siblingRow, upBool);
              e.preventDefault();
              return true;
            }

            var tableNode = editor.dom.getParent(currentRow, 'table');
            var middleNode = currentRow.parentNode;
            var parentNodeName = middleNode.nodeName.toLowerCase();
            if (parentNodeName === 'tbody' || parentNodeName === (upBool ? 'tfoot' : 'thead')) {
              var targetParent = getTargetParent(upBool, tableNode, middleNode, 'tbody');
              if (targetParent !== null) {
                return moveToRowInTarget(upBool, targetParent, sourceNode);
              }
            }

            return escapeTable(upBool, currentRow, siblingDirection, tableNode);
          }

          function getTargetParent(upBool, topNode, secondNode, nodeName) {
            var tbodies = editor.dom.select('>' + nodeName, topNode);
            var position = tbodies.indexOf(secondNode);
            if (upBool && position === 0 || !upBool && position === tbodies.length - 1) {
              return getFirstHeadOrFoot(upBool, topNode);
            } else if (position === -1) {
              var topOrBottom = secondNode.tagName.toLowerCase() === 'thead' ? 0 : tbodies.length - 1;
              return tbodies[topOrBottom];
            }

            return tbodies[position + (upBool ? -1 : 1)];
          }

          function getFirstHeadOrFoot(upBool, parent) {
            var tagName = upBool ? 'thead' : 'tfoot';
            var headOrFoot = editor.dom.select('>' + tagName, parent);
            return headOrFoot.length !== 0 ? headOrFoot[0] : null;
          }

          function moveToRowInTarget(upBool, targetParent, sourceNode) {
            var targetRow = getChildForDirection(targetParent, upBool);

            if (targetRow) {
              moveCursorToRow(editor, sourceNode, targetRow, upBool);
            }

            e.preventDefault();
            return true;
          }

          function escapeTable(upBool, currentRow, siblingDirection, table) {
            var tableSibling = table[siblingDirection];

            if (tableSibling) {
              moveCursorToStartOfElement(tableSibling);
              return true;
            }

            var parentCell = editor.dom.getParent(table, 'td,th');
            if (parentCell) {
              return handle(upBool, parentCell, e);
            }

            var backUpSibling = getChildForDirection(currentRow, !upBool);
            moveCursorToStartOfElement(backUpSibling);
            e.preventDefault();
            return false;
          }

          function getChildForDirection(parent, up) {
            var child = parent && parent[up ? 'lastChild' : 'firstChild'];
            // BR is not a valid table child to return in this case we return the table cell
            return child && child.nodeName === 'BR' ? editor.dom.getParent(child, 'td,th') : child;
          }

          function moveCursorToStartOfElement(n) {
            editor.selection.setCursorLocation(n, 0);
          }

          function isVerticalMovement() {
            return key == VK.UP || key == VK.DOWN;
          }

          function isInTable(editor) {
            var node = editor.selection.getNode();
            var currentRow = editor.dom.getParent(node, 'tr');
            return currentRow !== null;
          }

          function columnIndex(column) {
            var colIndex = 0;
            var c = column;
            while (c.previousSibling) {
              c = c.previousSibling;
              colIndex = colIndex + getSpanVal(c, "colspan");
            }
            return colIndex;
          }

          function findColumn(rowElement, columnIndex) {
            var c = 0, r = 0;

            each(rowElement.children, function (cell, i) {
              c = c + getSpanVal(cell, "colspan");
              r = i;
              if (c > columnIndex) {
                return false;
              }
            });
            return r;
          }

          function moveCursorToRow(ed, node, row, upBool) {
            var srcColumnIndex = columnIndex(editor.dom.getParent(node, 'td,th'));
            var tgtColumnIndex = findColumn(row, srcColumnIndex);
            var tgtNode = row.childNodes[tgtColumnIndex];
            var rowCellTarget = getChildForDirection(tgtNode, upBool);
            moveCursorToStartOfElement(rowCellTarget || tgtNode);
          }

          function shouldFixCaret(preBrowserNode) {
            var newNode = editor.selection.getNode();
            var newParent = editor.dom.getParent(newNode, 'td,th');
            var oldParent = editor.dom.getParent(preBrowserNode, 'td,th');

            return newParent && newParent !== oldParent && checkSameParentTable(newParent, oldParent);
          }

          function checkSameParentTable(nodeOne, NodeTwo) {
            return editor.dom.getParent(nodeOne, 'TABLE') === editor.dom.getParent(NodeTwo, 'TABLE');
          }

          if (isVerticalMovement() && isInTable(editor)) {
            var preBrowserNode = editor.selection.getNode();
            Delay.setEditorTimeout(editor, function () {
              if (shouldFixCaret(preBrowserNode)) {
                handle(!e.shiftKey && key === VK.UP, preBrowserNode, e);
              }
            }, 0);
          }
        }

        editor.on('KeyDown', function (e) {
          eventHandler(e);
        });
      }
1050717
function _updateNodes(nodes, source) {
  // Enter any new nodes at the parent's previous position.
  nodes.enter().append('g')
    .attr('transform', function(d) {
      var node = _getVertexNode(d, "x0") || source;
      node = _layout.projector(node.x0, node.y0);
      return 'translate(' + node.x + ',' + node.y + ')';
    })
    .on({
      mouseover: _onMouseOver,
      mouseout: _tip.hide,
      mousedown: _onMouse,
      mousemove: _onMouse,
      dblclick: _onDblclick
    })
    .style('opacity', 1e-6)
    .each(_addContent);

  // Transition nodes to their new position.
  nodes.transition()
    .duration(DURATION)
    .attr('transform', function(d) {
      d = _layout.projector(d.x, d.y);
      return 'translate(' + d.x + ',' + d.y + ')';
    })
    .style('opacity', 1);

  // Transition exiting nodes to the parent's new position.
  nodes.exit().transition()
    .duration(DURATION)
    .attr('transform', function(d) {
      var node = _getVertexNode(d, "x") || source;
      node = _layout.projector(node.x, node.y);
      return 'translate(' + node.x + ',' + node.y + ')';
    })
    .style('opacity', 1e-6)
    .remove();
}
368365
function(array) {
    var length = array.length;

    array[0] += array[1];

    var headNode, tailNode, topNode, temp;
    for (headNode = 0, tailNode = 1, topNode = 2;
         tailNode < (length - 1);
         tailNode++) {
      if ((topNode >= length) || (array[headNode] < array[topNode])) {
        temp = array[headNode];
        array[headNode++] = tailNode;
      } else {
        temp = array[topNode++];
      }

      if ((topNode >= length) ||
          ((headNode < tailNode) && (array[headNode] < array[topNode]))) {
        temp += array[headNode];
        array[headNode++] = tailNode + length;
      } else {
        temp += array[topNode++];
      }

      array[tailNode] = temp;
    }
  }
907453
protected function moveNode()
    {
        if ($this->exists) {
            if (is_null($this->closure->ancestor)) {
                $primaryKey = $this->getKey();
                $this->closure->ancestor = $primaryKey;
                $this->closure->descendant = $primaryKey;
                $this->closure->depth = 0;
            }

            if ($this->isDirty($this->getParentIdColumn())) {
                $this->reorderSiblings(true);
                $this->closure->moveNodeTo($this->parent_id);
            }
        }
    }
1019532
function(nodes) {
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i] instanceof RiakNode) {
                this.nodes.push(nodes[i]);
            }
        }
        return this;
    }
1228795
def do_HEAD(self):
        """"""
        self.queue.put(self.headers.get("User-Agent"))
        self.send_response(six.moves.BaseHTTPServer.HTTPStatus.OK)
        self.send_header("Location", self.path)
        self.end_headers()
202189
function(nodes) {
                var box = new kity.Box();
                var i, node, matrix, contentBox;
                for (i = 0; i < nodes.length; i++) {
                    node = nodes[i];
                    matrix = node.getLayoutTransform();
                    contentBox = node.getContentBox();
                    box = box.merge(matrix.transformBox(contentBox));
                }
                return box;
            }
947610
def clear(self):
		'''
		
		'''
		for node in self.dli():
			node.empty = True
			node.key = None
			node.value = None
		
		self.head = _dlnode()
		self.head.next = self.head
		self.head.prev = self.head
		self.listSize = 1
		
		self.table.clear()
		
		# status var
		self.hit_cnt = 0 
		self.miss_cnt = 0
		self.remove_cnt = 0
266121
function allNodesAtLocation(location) {
        var nodes = [];
        exports.root.each(function each(n) {
            if (n.type === DOMNode.TYPE_ELEMENT && n.isAtLocation(location)) {
                nodes.push(n);
            }
        });
        return nodes;
    }
781531
function moveSinksRight(nodes, maxDepth) {
    zrUtil.each(nodes, function (node) {
        if (!isNodeDepth(node) && !node.outEdges.length) {
            node.setLayout({depth: maxDepth}, true);
        }
    });
}
86635
function moveChild(tagName, newPos) {
      var parent = this.parent;
      var tags;
      // no parent no move
      if (!parent) { return }

      tags = parent.tags[tagName];

      if (isArray(tags))
        { tags.splice(newPos, 0, tags.splice(tags.indexOf(this), 1)[0]); }
      else { arrayishAdd(parent.tags, tagName, this); }
    }
1335732
function _onNodesRemoved(nodes) {
        var i;
        //iterate on removed nodes
        for (i = 0; i < nodes.length; i++) {

            // check for external JS files
            if (Utils.isExternalScript(nodes[i])) {
                _transport.send(JSON.stringify({
                    method: 'ScriptRemoved',
                    src: nodes[i].src
                }));
            }
            //check for external StyleSheets
            if (Utils.isExternalStylesheet(nodes[i])) {
                CSS.notifyStylesheetRemoved(nodes[i].href);
            }
        }
    }
74646
def link_head(self, node):
        ''' '''
        assert not node.tail
        old_head = self.head

        if old_head:
            assert old_head.tail == self
            old_head.tail = node
            node.head = old_head

        node.tail = self
        self.head = node