Remove all elements from the set and return them in order. Traverse the
link list, don't worry about hashtable - faster version of the parent
method.
351287
public List<T> pollAll() {
    List<T> retList = new ArrayList<T>(size);
    pollAllToList(retList);
    return retList;
  }
297520
private static <T> void shrinkSet(final Set<T> set, int newSize) {
    if (!(set instanceof LinkedHashSet))
      throw new IllegalStateException("Cannot shrink a set which is not of type LinkedHashSet");
    if (newSize > set.size())
      throw new IllegalStateException("Cannot shrink a set of size " + set.size() + " to new size " + newSize);
    Iterator<T> entryIterator = set.iterator();
    int count = 0;
    while (count < newSize) {
      entryIterator.next();
      count++;
    }
    while (entryIterator.hasNext()) {
      entryIterator.next();
      entryIterator.remove();
    }
  }
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;
    }
970479
public void removeAll()
    {
        if (m_aRecords != null)
        {
            for (int iArrayIndex = 0; iArrayIndex < MAX_RECORD_ARRAY_SIZE; iArrayIndex++)
            {   // Free the objects that are no longer used
                this.freeElement(m_aRecords[iArrayIndex]);
                m_aRecords[iArrayIndex] = null;
            }
            m_aRecords = null;
        }
        m_iRecordListStep = 1;
        m_iRecordListEnd = 0;
        m_iRecordListMax = 0; // Current size of the record list (records scanned) (-1 - unknown)
    }
1215005
public List<AstNode> removeAllChildren() {
        if (this.children.isEmpty()) {
            return new ArrayList<AstNode>(0);
        }
        List<AstNode> copyOfChildren = new ArrayList<AstNode>(this.children);
        for (Iterator<AstNode> childIter = this.children.iterator(); childIter.hasNext();) {
            AstNode child = childIter.next();
            childIter.remove();
            child.parent = null;
        }
        return copyOfChildren;
    }
892983
public Iterator iterator() {
        // remove garbage collected elements
        processQueue();

        // get an iterator of the superclass WeakHashSet
        final Iterator i = super.iterator();

        return new Iterator() {
            public boolean hasNext() {
                return i.hasNext();
            }

            public Object next() {
                // unwrap the element
                return getReferenceObject((WeakReference) i.next());
            }

            public void remove() {
                // remove the element from the HashSet
                i.remove();
            }
        };
    }
321177
def remove_elements(parent_to_parse, element_paths, clear_empty=False):
    

    element = get_element(parent_to_parse)
    removed = []

    if element is None or not element_paths:
        return removed

    if isinstance(element_paths, string_types):
        rem = remove_element(element, element_paths, clear_empty)
        removed.extend(rem if isinstance(rem, list) else [rem])
    else:
        for xpath in element_paths:
            rem = remove_element(element, xpath, clear_empty)
            removed.extend(rem if isinstance(rem, list) else [rem])

    return removed
300861
@Pure
	public SortedSet<Integer> toSortedSet() {
		final SortedSet<Integer> theset = new TreeSet<>();
		if (this.values != null) {
			for (int idxStart = 0; idxStart < this.values.length - 1; idxStart += 2) {
				for (int n = this.values[idxStart]; n <= this.values[idxStart + 1]; ++n) {
					theset.add(n);
				}
			}
		}
		return theset;
	}
188869
public Iterator<E> iterator() {

        return new Iterator<E>() {

            public boolean hasNext() {
                return enumeration.hasMoreElements();
            }

            public E next() {
                return enumeration.nextElement();
            }

            public void remove() {
                throw new UnsupportedOperationException("IterableEnumeration does not support remove");
            }
        };
    }
47851
public void removePermutations(List<Integer> removed) {

		int[] permutations = new int[this.permutations.length];

		int index = 0;
		permutations:
		for (int j : this.permutations) {
			for (int i = 0; i < removed.size(); i++) {
				if(removed.get(i) == j) {
					// skip this
					removed.remove(i);

					continue permutations;
				}
			}

			permutations[index] = j;

			index++;
		}

		int[] effectivePermutations = new int[index];
		System.arraycopy(permutations, 0, effectivePermutations, 0, index);
		
		this.rotations = new int[permutations.length];
		this.reset = new int[permutations.length];
		this.permutations = effectivePermutations;
		Arrays.sort(permutations); // ascending order to make the permutation logic work
	}
882484
public List<RemoveMethodType<SessionBeanType<T>>> getAllRemoveMethod()
   {
      List<RemoveMethodType<SessionBeanType<T>>> list = new ArrayList<RemoveMethodType<SessionBeanType<T>>>();
      List<Node> nodeList = childNode.get("remove-method");
      for(Node node: nodeList)
      {
         RemoveMethodType<SessionBeanType<T>>  type = new RemoveMethodTypeImpl<SessionBeanType<T>>(this, "remove-method", childNode, node);
         list.add(type);
      }
      return list;
   }
712050
private void clean() {
        Iterator<Entry<K, WeakReference<V>>> iter = entrySet().iterator();
        while (iter.hasNext()) {
            Entry<K, WeakReference<V>> e = iter.next();
            if (e != null && e.getValue() != null
                && e.getValue().get() == null) {
                iter.remove();
            }
        }
    }
666566
public boolean remove()
    {
        if (_last1.key() == null)
            throw new java.util.NoSuchElementException(
                                                      "remove() without calling next()");

        boolean result = internalRemove();

        return result;
    }
737686
@Override
	public void prune() {
		Iterator<PointIndex<Point>> iter = allPoints.iterator();
		int index = 0;
		while( iter.hasNext() ) {
			iter.next();
			if (origErrors[index++] >= pruneVal) {
				iter.remove();
			}
		}
	}
320414
@Override
    public Set<T> next() {
        Set<T> subset = new LinkedHashSet<>();
        next(subset);
        return subset;
    }
1276329
public void clear() {
		//clear each collection to make previously returned lists empty
		for (List<V> value : map.values()) {
			value.clear();
		}
		map.clear();
	}
1285117
def _ordered_iterator(self):
        
        # A list of tuples, each with:
        #   * The iterable
        #   * The QuerySet number
        #   * The next value
        #
        # (Remember that each QuerySet is already sorted.)
        iterables = []
        for i, qs in zip(self._queryset_idxs, self._querysets):
            it = iter(qs)
            try:
                value = next(it)
            except StopIteration:
                # If this is already empty, just skip it.
                continue
            # Set the QuerySet number so that the comparison works properly.
            setattr(value, '#', i)
            iterables.append((it, i, value))

        # The offset of items returned.
        index = 0

        # Create a comparison function based on the requested ordering.
        _comparator = self._generate_comparator(self._order_by)
        def comparator(tuple_1, tuple_2):
            # The last element in each tuple is the actual item to compare.
            return _comparator(tuple_1[2], tuple_2[2])
        comparator = functools.cmp_to_key(comparator)

        # If in reverse mode, get the last value instead of the first value from
        # ordered_values below.
        if self._standard_ordering:
            next_value_ind = 0
        else:
            next_value_ind = -1

        # Continue until all iterables are empty.
        while iterables:
            # If there's only one iterator left, don't bother sorting.
            if len(iterables) > 1:
                # Sort the current values for each iterable.
                iterables = sorted(iterables, key=comparator)

                # The next ordering item is in the first position, unless we're
                # in reverse mode.
                it, i, value = iterables[next_value_ind]
            else:
                it, i, value = iterables[0]

            # Return the next value if we're within the slice of interest.
            if self._low_mark <= index:
                yield value
            index += 1
            # We've left the slice of interest, we're done.
            if index == self._high_mark:
                return

            # Iterate the iterable that just lost a value.
            try:
                value = next(it)
                # Set the QuerySet number so that the comparison works properly.
                setattr(value, '#', i)
                iterables[next_value_ind] = it, i, value
            except StopIteration:
                # This iterator is done, remove it.
                del iterables[next_value_ind]