Inserts a new node before the given one .
432704
int insertElement(int list, int beforeNode, int data) {
		int node = newNode_();
		int prev = -1;
		if (beforeNode != nullNode()) {
			prev = getPrev(beforeNode);
			setPrev_(beforeNode, node);
		}

		setNext_(node, beforeNode);
		if (prev != nullNode())
			setNext_(prev, node);

		int head = m_lists.getField(list, 0);

		if (beforeNode == head)
			m_lists.setField(list, 0, node);
		if (beforeNode == nullNode()) {
			int tail = m_lists.getField(list, 1);
			setPrev_(node, tail);
			if (tail != -1)
				setNext_(tail, node);

			m_lists.setField(list, 1, node);
		}

		setData(node, data);
		setListSize_(list, getListSize(list) + 1);

		if (m_b_store_list_index_with_node)
			setList_(node, list);

		return node;
	}
917409
public boolean insertBefore(final Node newNode, final Node oldNode) {
        if (oldNode == null || newNode == null) {
            return false;
        }

        int index = nodes.indexOf(oldNode);
        if (index != -1) {
            // Remove the parent from the new node if one exists
            if (newNode.getParent() != null) {
                newNode.removeParent();
            }
            newNode.setParent(this);
            // Add the node to the relevant list
            if (newNode instanceof Level) {
                levels.add((Level) newNode);
            } else if (newNode instanceof SpecTopic) {
                topics.add((SpecTopic) newNode);
            }
            // Insert the node
            if (index == 0) {
                nodes.addFirst(newNode);
            } else {
                nodes.add(index - 1, newNode);
            }
            return true;
        } else {
            return false;
        }
    }
901140
def insertBefore(self, child: Node, ref_node: Node) -> Node:
        
        if self.connected:
            self._insert_before_web(child, ref_node)
        return self._insert_before(child, ref_node)
401381
public void addChildBefore(Node newChild, Node node) {
        if (newChild.next != null)
            throw new RuntimeException(
                      "newChild had siblings in addChildBefore");
        if (first == node) {
            newChild.next = first;
            first = newChild;
            return;
        }
        Node prev = getChildBefore(node);
        addChildAfter(newChild, prev);
    }
784123
@Override
	public void listInsertBefore(final T currentElement, final T newElement) throws FrameworkException {

		if (currentElement.getUuid().equals(newElement.getUuid())) {
			throw new IllegalStateException("Cannot link a node to itself!");
		}

		final T previousElement = listGetPrevious(currentElement);
		if (previousElement == null) {

			linkNodes(getSiblingLinkType(), newElement, currentElement);

		} else {
			// delete old relationship
			unlinkNodes(getSiblingLinkType(), previousElement, currentElement);

			// dont create self link
			if (!previousElement.getUuid().equals(newElement.getUuid())) {
				linkNodes(getSiblingLinkType(), previousElement, newElement);
			}

			// dont create self link
			if (!newElement.getUuid().equals(currentElement.getUuid())) {
				linkNodes(getSiblingLinkType(), newElement, currentElement);
			}
		}
	}
1334283
def prepend(self, *nodes: Union[str, AbstractNode]) -> None:
        """"""
        node = _to_node_list(nodes)
        if self.firstChild:
            self.insertBefore(node, self.firstChild)
        else:
            self.appendChild(node)
933753
function prepend (el, child) {
  if (el.firstChild) {
    el.insertBefore(child, el.firstChild)
  } else {
    el.appendChild(child)
  }
}
236107
def insert_or_append(parent, node, next_sibling):
    
    # simple insert
    if next_sibling:
        parent.insertBefore(node, next_sibling)
    else:
        parent.appendChild(node)
1118778
def insert(self, i, x):
        """"""
        if i == len(self):  # end of list or empty list: append
            self.append(x)
        elif len(self.matches) > i:
            # create a new xml node at the requested position
            insert_index = self.matches[i].getparent().index(self.matches[i])
            _create_xml_node(self.xast, self.node, self.context, insert_index)
            # then use default set logic
            self[i] = x
        else:
            raise IndexError("Can't insert '%s' at index %d - list length is only %d" \
                            % (x, i, len(self)))
1291704
def insert_first(self, val):
        

        self.head = Node(val, next_node=self.head)
        return True
658926
function safeInsert(root, curr, next) {
      root.insertBefore(curr, next.parentNode && next);
    }
751776
def replace(self, new_node):
        """"""
        cur_node = self.cur_node
        nodestack = self.nodestack
        cur = nodestack.pop()
        prev = nodestack[-1]
        index = prev[-1] - 1
        oldnode, name = prev[-2][index]
        assert cur[0] is cur_node is oldnode, (cur[0], cur_node, prev[-2],
                                               index)
        parent = prev[0]
        if isinstance(parent, list):
            parent[index] = new_node
        else:
            setattr(parent, name, new_node)
631705
function insertTo(root, node, before) {
  if (!root) return
  root.insertBefore(before, node)
  root.removeChild(node)
}
466882
private int insertTailoredNodeAfter(int index, int strength) {
        assert(0 <= index && index < nodes.size());
        if(strength >= Collator.SECONDARY) {
            index = findCommonNode(index, Collator.SECONDARY);
            if(strength >= Collator.TERTIARY) {
                index = findCommonNode(index, Collator.TERTIARY);
            }
        }
        // Postpone insertion:
        // Insert the new node before the next one with a strength at least as strong.
        long node = nodes.elementAti(index);
        int nextIndex;
        while((nextIndex = nextIndexFromNode(node)) != 0) {
            node = nodes.elementAti(nextIndex);
            if(strengthFromNode(node) <= strength) { break; }
            // Skip the next node which has a weaker (larger) strength than the new one.
            index = nextIndex;
        }
        node = IS_TAILORED | nodeFromStrength(strength);
        return insertNodeBetween(index, nextIndex, node);
    }
531683
def insert_before(old, new):
    
    parent = old.getparent()
    parent.insert(parent.index(old), new)
55763
function prepend(nodesToPrepend) {
                var nodes = Array.prototype.slice.call(nodesToPrepend),
                    i = nodes.length;

                while (i--) {
                    el.insertBefore(nodes[i], el.firstChild);
                }
            }
691616
def insert(self, key):
        
        # Create new node
        n = TreeNode(key)
        if not self.node:
            self.node = n
            self.node.left = AvlTree()
            self.node.right = AvlTree()
        elif key < self.node.val:
            self.node.left.insert(key)
        elif key > self.node.val:
            self.node.right.insert(key)
        self.re_balance()