Removes this segment of a circularly-linked list and returns its successor.
Returns null if the list is now empty.
438922
public Segment pop() {
    Segment result = next != this ? next : null;
    prev.next = next;
    next.prev = prev;
    next = null;
    prev = null;
    return result;
  }
1308414
@Nullable V removeNoWriter(Object key) {
    Node<K, V> node = data.remove(nodeFactory.newLookupKey(key));
    if (node == null) {
      return null;
    }

    V oldValue;
    synchronized (node) {
      oldValue = node.getValue();
      if (node.isAlive()) {
        node.retire();
      }
    }

    RemovalCause cause;
    if (oldValue == null) {
      cause = RemovalCause.COLLECTED;
    } else if (hasExpired(node, expirationTicker().read())) {
      cause = RemovalCause.EXPIRED;
    } else {
      cause = RemovalCause.EXPLICIT;
    }

    if (hasRemovalListener()) {
      @SuppressWarnings("unchecked")
      K castKey = (K) key;
      notifyRemoval(castKey, oldValue, cause);
    }
    afterWrite(new RemovalTask(node));
    return (cause == RemovalCause.EXPLICIT) ? oldValue : null;
  }
745157
function remove(node) {
    var next = node.nextSibling || node.parentNode;

    node.parentNode.removeChild(node);

    return next;
}
1002518
public Object remove(int index) {

        //Check that the index is less than size because the getInternal
        //method is being called with index - 1 and its checks will therefore
        //not be useful in this case.
        if (index >= size()) {
            throw new IndexOutOfBoundsException("Index out of bounds: "
                                                + index + " >= " + size());
        }

        //Get the node that is previous to the node being removed
        Node previousToRemove;

        if (index == 0) {
            previousToRemove = first;
        } else {
            previousToRemove = getInternal(index - 1);
        }

        //previousToRemove.next will never be null because of the check above
        //that index < size.
        Node toRemove = previousToRemove.next;

        previousToRemove.next = toRemove.next;

        elementCount--;

        //If they removed at the last valid index, then a the last element
        //was removed, therfore update the last pointer
        if (last == toRemove) {
            last = previousToRemove;
        }

        return toRemove.data;
    }
1352184
def delete(self):
        
        # we'll have to manually run through all the nodes that are going
        # to be deleted and remove nodes from the list if an ancestor is
        # already getting removed, since that would be redundant
        removed = {}
        for node in self.order_by('depth', 'path'):
            found = False
            for depth in range(1, int(len(node.path) / node.steplen)):
                path = node._get_basepath(node.path, depth)
                if path in removed:
                    # we are already removing a parent of this node
                    # skip
                    found = True
                    break
            if not found:
                removed[node.path] = node

        # ok, got the minimal list of nodes to remove...
        # we must also remove their children
        # and update every parent node's numchild attribute
        # LOTS OF FUN HERE!
        parents = {}
        toremove = []
        for path, node in removed.items():
            parentpath = node._get_basepath(node.path, node.depth - 1)
            if parentpath:
                if parentpath not in parents:
                    parents[parentpath] = node.get_parent(True)
                parent = parents[parentpath]
                if parent and parent.numchild > 0:
                    parent.numchild -= 1
                    parent.save()
            if node.is_leaf():
                toremove.append(Q(path=node.path))
            else:
                toremove.append(Q(path__startswith=node.path))

        # Django will handle this as a SELECT and then a DELETE of
        # ids, and will deal with removing related objects
        if toremove:
            qset = get_result_class(self.model).objects.filter(reduce(operator.or_, toremove))
            super(MP_NodeQuerySet, qset).delete()
78211
private void unlinkFirst(Node<E> first, Node<E> next) {
        // assert first != null;
        // assert next != null;
        // assert first.item == null;
        for (Node<E> o = null, p = next, q;;) {
            if (p.item != null || (q = p.next) == null) {
                if (o != null && p.prev != p &&
                    NEXT.compareAndSet(first, next, p)) {
                    skipDeletedPredecessors(p);
                    if (first.prev == null &&
                        (p.next == null || p.item != null) &&
                        p.prev == first) {

                        updateHead(); // Ensure o is not reachable from head
                        updateTail(); // Ensure o is not reachable from tail

                        // Finally, actually gc-unlink
                        NEXT.setRelease(o, o);
                        PREV.setRelease(o, prevTerminator());
                    }
                }
                return;
            }
            else if (p == q)
                return;
            else {
                o = p;
                p = q;
            }
        }
    }
1067388
int removeVertex(int vertex, boolean b_left_segment) {
		int path = getPathFromVertex(vertex);
		int prev = getPrevVertex(vertex);
		int next = getNextVertex(vertex);
		if (prev != -1)
			setNextVertex_(prev, next);

		int path_size = getPathSize(path);

		if (vertex == getFirstVertex(path)) {
			setFirstVertex_(path, path_size > 1 ? next : -1);
		}

		if (next != -1)
			setPrevVertex_(next, prev);

		if (vertex == getLastVertex(path)) {
			setLastVertex_(path, path_size > 1 ? prev : -1);
		}

		if (prev != -1 && next != -1) {
			int vindex_prev = getVertexIndex(prev);
			int vindex_next = getVertexIndex(next);
			if (b_left_segment) {
				Segment seg = getSegmentFromIndex_(vindex_prev);
				if (seg != null) {
					Point2D pt = new Point2D();
					m_vertices.getXY(vindex_next, pt);
					seg.setEndXY(pt);
				}
			} else {
				int vindex_erased = getVertexIndex(vertex);
				Segment seg = getSegmentFromIndex_(vindex_erased);
				setSegmentToIndex_(vindex_prev, seg);
				if (seg != null) {
					Point2D pt = m_vertices.getXY(vindex_prev);
					seg.setStartXY(pt);
				}
			}
		}

		setPathSize_(path, path_size - 1);
		int geometry = getGeometryFromPath(path);
		setGeometryVertexCount_(geometry, getPointCount(geometry) - 1);
		freeVertex_(vertex);
		return next;
	}
5266
E unlinkFirst() {
    final E f = first;
    final E next = f.getNext();
    f.setNext(null);

    first = next;
    if (next == null) {
      last = null;
    } else {
      next.setPrevious(null);
    }
    return f;
  }
1133089
private static <V> TreeEntry<V> successor(TreeEntry<V> t) {
        if (t == null) {
            return null;
        } else if (t.right != null) {
            TreeEntry<V> p = t.right;
            while (p.left != null) {
                p = p.left;
            }
            return p;
        } else {
            TreeEntry<V> p = t.parent;
            TreeEntry<V> ch = t;
            while (p != null && ch == p.right) {
                ch = p;
                p = p.parent;
            }
            return p;
        }
    }
334349
void unlink(Node<E> x) {
        // assert x != null;
        // assert x.item == null;
        // assert x != PREV_TERMINATOR;
        // assert x != NEXT_TERMINATOR;

        final Node<E> prev = x.prev;
        final Node<E> next = x.next;
        if (prev == null) {
            unlinkFirst(x, next);
        } else if (next == null) {
            unlinkLast(x, prev);
        } else {
            // Unlink interior node.
            //
            // This is the common case, since a series of polls at the
            // same end will be "interior" removes, except perhaps for
            // the first one, since end nodes cannot be unlinked.
            //
            // At any time, all active nodes are mutually reachable by
            // following a sequence of either next or prev pointers.
            //
            // Our strategy is to find the unique active predecessor
            // and successor of x.  Try to fix up their links so that
            // they point to each other, leaving x unreachable from
            // active nodes.  If successful, and if x has no live
            // predecessor/successor, we additionally try to gc-unlink,
            // leaving active nodes unreachable from x, by rechecking
            // that the status of predecessor and successor are
            // unchanged and ensuring that x is not reachable from
            // tail/head, before setting x's prev/next links to their
            // logical approximate replacements, self/TERMINATOR.
            Node<E> activePred, activeSucc;
            boolean isFirst, isLast;
            int hops = 1;

            // Find active predecessor
            for (Node<E> p = prev; ; ++hops) {
                if (p.item != null) {
                    activePred = p;
                    isFirst = false;
                    break;
                }
                Node<E> q = p.prev;
                if (q == null) {
                    if (p.next == p) // j2objc: PREV_TERMINATOR
                        return;
                    activePred = p;
                    isFirst = true;
                    break;
                }
                else if (sentinel() == q) // j2objc: q == p.prev == sentinel means node GC-unlinked
                    return;
                else
                    p = q;
            }

            // Find active successor
            for (Node<E> p = next; ; ++hops) {
                if (p.item != null) {
                    activeSucc = p;
                    isLast = false;
                    break;
                }
                Node<E> q = p.next;
                if (q == null) {
                    if (p.prev == p) // j2objc: NEXT_TERMINATOR
                        return;
                    activeSucc = p;
                    isLast = true;
                    break;
                }
                else if (sentinel() == q) // j2objc: q == p.next == sentinel means node GC-unlinked
                    return;
                else
                    p = q;
            }

            // TODO: better HOP heuristics
            if (hops < HOPS
                // always squeeze out interior deleted nodes
                && (isFirst | isLast))
                return;

            // Squeeze out deleted nodes between activePred and
            // activeSucc, including x.
            skipDeletedSuccessors(activePred);
            skipDeletedPredecessors(activeSucc);

            // Try to gc-unlink, if possible
            if ((isFirst | isLast) &&

                // Recheck expected state of predecessor and successor
                (activePred.next == activeSucc) &&
                (activeSucc.prev == activePred) &&
                (isFirst ? activePred.prev == null : activePred.item != null) &&
                (isLast  ? activeSucc.next == null : activeSucc.item != null)) {

                updateHead(); // Ensure x is not reachable from head
                updateTail(); // Ensure x is not reachable from tail

                // Finally, actually gc-unlink
                x.lazySetPrev(isFirst ? prevTerminator() : sentinel());
                x.lazySetNext(isLast  ? nextTerminator() : sentinel());
            }
        }
    }
471043
public T remove() {
        lock.lock();

        try {
            if(queue.isEmpty())
                return null;
            El<T> el=queue.poll();
            count-=el.size;
            not_full.signalAll();
            return el.el;
        }
        finally {
            lock.unlock();
        }
    }
952757
void deleteElement(int list, int prevNode, int node) {
		if (prevNode != nullNode()) {
			assert (m_listNodes.getField(prevNode, 1) == node);
			m_listNodes.setField(prevNode, 1, m_listNodes.getField(node, 1));
			if (m_lists.getField(list, 1) == node)// deleting a tail
			{
				m_lists.setField(list, 1, prevNode);
			}
		} else {
			assert (m_lists.getField(list, 0) == node);
			m_lists.setField(list, 0, m_listNodes.getField(node, 1));
			if (m_lists.getField(list, 1) == node) {// removing last element
				assert (m_listNodes.getField(node, 1) == nullNode());
				m_lists.setField(list, 1, nullNode());
			}
		}
		freeNode_(node);
	}
1197699
public ByteArray removeLast() {
        Node node = bas.removeLast();
        return node == null ? null : node.getByteArray();
    }
42152
public ObjectSinkNode removeFirst() {
        if ( this.firstNode == null ) {
            return null;
        }
        final ObjectSinkNode node = this.firstNode;
        this.firstNode = node.getNextObjectSinkNode();
        node.setNextObjectSinkNode( null );
        if ( this.firstNode != null ) {
            this.firstNode.setPreviousObjectSinkNode( null );
        } else {
            this.lastNode = null;
        }
        this.size--;
        return node;
    }
122370
private QNode reclean() {
        /*
         * cleanMe is, or at one time was, predecessor of cancelled
         * node s that was the tail so could not be unspliced.  If s
         * is no longer the tail, try to unsplice if necessary and
         * make cleanMe slot available.  This differs from similar
         * code in clean() because we must check that pred still
         * points to a cancelled node that must be unspliced -- if
         * not, we can (must) clear cleanMe without unsplicing.
         * This can loop only due to contention on casNext or
         * clearing cleanMe.
         */
        QNode pred;
        while ((pred = this.cleanMe.get()) != null) {
            QNode t = getValidatedTail();
            QNode s = pred.next;
            if (s != t) {
                QNode sn;
                if (s == null || s == pred || s.get() != s ||
                    (sn = s.next) == s || pred.casNext(s, sn)) {
                    this.cleanMe.compareAndSet(pred, null);
                }
            } else {
                break;
            }
        }
        return pred;
    }
1119301
public synchronized void clear() {

        // remove all objects from the linked list from the tail to the head:
        I_CmsLruCacheObject currentObject = m_listTail;
        while (currentObject != null) {
            currentObject = currentObject.getNextLruObject();
            removeTail();
        }

        // reset the data structure
        m_objectCosts = 0;
        m_objectCount = 0;
        m_listHead = null;
        m_listTail = null;
    }
785937
public T removeFirst() {
		if (isEmpty()) {
			return null;
		}
		T firstElement = elements[firstIndex];
		elements[firstIndex] = null;
		firstIndex = incrementIndex(firstIndex, 0);
		return firstElement;
	}