Unlinks matched (typically cancelled) nodes encountered in a
traversal from head.
3067
private void sweep() {
        for (Node p = head, s, n; p != null && (s = p.next) != null; ) {
            if (!s.isMatched())
                // Unmatched nodes are never self-linked
                p = s;
            else if ((n = s.next) == null) // trailing node is pinned
                break;
            else if (UNLINKED == n)    // stale
                // No need to also check for p == s, since that implies s == n
                p = head;
            else
                p.casNext(s, n);
        }
    }
953281
def unlink(self):
		
		self._tokenizer = None
		self._rowbuilder = None
		super(TableStream, self).unlink()
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
635252
def cleanup(self):
        """"""
        for path in self.paths:
            if isinstance(path, tuple):
                os.close(path[0])
                os.unlink(path[1])
            else:
                shutil.rmtree(path)
        self.paths = []
243978
private boolean findAndRemove(Object e) {
        if (e != null) {
            for (Node pred = null, p = head; p != null; ) {
                Object item = p.item;
                if (p.isData) {
                    if (item != null && item != FORGOTTEN && e.equals(item) &&
                        p.tryMatchData()) {
                        unsplice(pred, p);
                        return true;
                    }
                }
                else if (item == null)
                    break;
                pred = p;
                if ((p = p.next) == UNLINKED) { // stale
                    pred = null;
                    p = head;
                }
            }
        }
        return false;
    }
1342612
final void unsplice(Node pred, Node s) {
        s.waiter = null; // disable signals
        /*
         * See above for rationale. Briefly: if pred still points to
         * s, try to unlink s.  If s cannot be unlinked, because it is
         * trailing node or pred might be unlinked, and neither pred
         * nor s are head or offlist, add to sweepVotes, and if enough
         * votes have accumulated, sweep.
         */
        if (pred != null && pred != s && pred.next == s) {
            Node n = s.next;
            if (n == null ||
                (n != UNLINKED && pred.casNext(s, n) && pred.isMatched())) {
                for (;;) {               // check if at, or could be, head
                    Node h = head;
                    if (h == pred || h == s || h == null)
                        return;          // at head or list empty
                    if (!h.isMatched())
                        break;
                    Node hn = h.next;
                    if (hn == null)
                        return;          // now empty
                    if (hn != UNLINKED && casHead(h, hn))
                        h.forgetNext();  // advance head
                }
                if (pred.next != UNLINKED && s.next != UNLINKED) { // recheck if offlist
                    for (;;) {           // sweep now if enough votes
                        int v = sweepVotes;
                        if (v < SWEEP_THRESHOLD) {
                            if (casSweepVotes(v, v + 1))
                                break;
                        }
                        else if (casSweepVotes(v, 0)) {
                            sweep();
                            break;
                        }
                    }
                }
            }
        }
    }
1140955
final void cleanStack() {
    boolean unlinked = false;
    Completion p;
    while ((p = stack) != null && !p.isLive()) // ensure head of stack live
      unlinked = casStack(p, p.next);
    if (p != null && !unlinked) { // try to unlink first nonlive
      for (Completion q = p.next; q != null;) {
        Completion s = q.next;
        if (q.isLive()) {
          p = q;
          q = s;
        } else {
          casNext(p, q, s);
          break;
        }
      }
    }
  }
1345842
void disconnectInvalidVertices() {
		// add elements with 1 or 2 edges
		openVertexes.clear();
		for (int idxVert = 0; idxVert < vertexes.size; idxVert++) {
			Vertex n = vertexes.get(idxVert);
			if( n.connections.size() == 1 || n.connections.size()==2) {
				openVertexes.add(n);
			}
		}

		// continue until there are no changes
		while( !openVertexes.isEmpty() ) {
			dirtyVertexes.clear();
			for (int idxVert = 0; idxVert < openVertexes.size(); idxVert++) {
				boolean remove = false;
				Vertex n = openVertexes.get(idxVert);
				if( n.connections.size() == 1 ) {
					remove = true;
				} else if( n.connections.size() == 2 ) {
					Edge ea = n.connections.get(0);
					Edge eb = n.connections.get(1);

					// Look for a common vertex that isn't 'n'
					remove = true;
					for (int i = 0; i < ea.dst.connections.size(); i++) {
						Vertex va = ea.dst.connections.get(i).dst;
						if( va == n )
							continue;
						for (int j = 0; j < eb.dst.connections.size(); j++) {
							Vertex vb = ea.dst.connections.get(j).dst;
							if( va == vb ) {
								remove = false;
								break;
							}
						}
					}
				}

				if( remove ) {
					// only go through the subset referenced the disconnected. Yes there could be duplicates
					// not worth the time to fix that
					for (int i = 0; i < n.connections.size(); i++) {
						dirtyVertexes.add( n.connections.get(i).dst );
					}
					removeReferences(n,EdgeType.CONNECTION);
				}
			}
			openVertexes.clear();
			openVertexes.addAll(dirtyVertexes);
		}

	}
885462
def truncate_repeated_single_step_traversals(match_query):
    """"""
    # Such traversals frequently happen as side-effects of the lowering process
    # of Backtrack blocks, and needlessly complicate the executed queries.
    new_match_traversals = []
    visited_locations = set()

    for current_match_traversal in match_query.match_traversals:
        ignore_traversal = False
        if len(current_match_traversal) == 1:
            # Single-step traversal detected. If its location was visited already, ignore it.
            single_step = current_match_traversal[0]
            if single_step.as_block is None:
                raise AssertionError(u'Unexpectedly found a single-step traversal with no as_block:'
                                     u' {} {}'.format(current_match_traversal, match_query))

            if single_step.as_block.location in visited_locations:
                # This location was visited before, omit the traversal.
                ignore_traversal = True

        if not ignore_traversal:
            # For each step in this traversal, mark its location as visited.
            for step in current_match_traversal:
                if step.as_block is not None:
                    visited_locations.add(step.as_block.location)

            new_match_traversals.append(current_match_traversal)

    return match_query._replace(match_traversals=new_match_traversals)
1004493
def remove_isolated_nodes_op(graph):
    
    rv = graph.copy()
    nodes = list(nx.isolates(rv))
    rv.remove_nodes_from(nodes)
    return rv
1049469
def __delete_node_links(self, node):
        
        for link in list(self._links.values()):
            if node in link.nodes:
                yield from self.delete_link(link.id, force_delete=True)
1210939
def remove_edge(self, p_from, p_to, p_remove_unconnected_nodes=True):
        
        if self.has_edge(p_from, p_to):
            self._edges[p_from].remove(p_to)

        try:
            del self._edge_numbers[(p_from, p_to)]
        except KeyError:
            return None

        if p_remove_unconnected_nodes:
            if self.is_isolated(p_from):
                self.remove_node(p_from)

            if self.is_isolated(p_to):
                self.remove_node(p_to)
291903
function() {
  var res = this.match(reLinkDestinationBraces);
  if (res) {  // chop off surrounding <..>:
    return unescape(res.substr(1, res.length - 2));
  } else {
    res = this.match(reLinkDestination);
    if (res !== null) {
      return unescape(res);
    } else {
      return null;
    }
  }
}
721168
private void unparkSuccessor(Node node) {
        /*
         * If status is negative (i.e., possibly needing signal) try
         * to clear in anticipation of signalling.  It is OK if this
         * fails or if status is changed by waiting thread.
         */
        int ws = node.waitStatus;
        if (ws < 0)
            node.compareAndSetWaitStatus(ws, 0);

        /*
         * Thread to unpark is held in successor, which is normally
         * just the next node.  But if cancelled or apparently null,
         * traverse backwards from tail to find the actual
         * non-cancelled successor.
         */
        Node s = node.next;
        if (s == null || s.waitStatus > 0) {
            s = null;
            for (Node p = tail; p != node && p != null; p = p.prev)
                if (p.waitStatus <= 0)
                    s = p;
        }
        if (s != null)
            LockSupport.unpark(s.thread);
    }
1192984
function _cleanUpTOCChildren(node) {

  if (!Array.isArray(node.children)) {
    return node;
  }

  if (_isExampleOrParameterLink(node)) {
    return null;
  }

  const filteredChildren = node.children.reduce((accu, nd) => {
    accu.push(_cleanUpTOCChildren(nd));
    return accu;
  }, []).filter(n => n);

  if (!filteredChildren.length) {
    return null;
  }

  return {
    ...node,
    children: filteredChildren
  };
}
838416
def delete_nodes(self, nodes: Iterable[str]):
        
        for n in nodes:
            if self.has_node(n):
                self.remove_node(n)
52332
def unlink(self):
        ''''''
        old_head = self.head
        old_tail = self.tail

        self.head = None
        self.tail = None

        if old_head:
            old_head.tail = old_tail

        if old_tail:
            old_tail.head = old_head