The method uses the runner technique in order to iterate over
head twice. If the list contains duplicates, the next-next is set
as the next node of the current node.
175517
public function removeDuplicates() {
        $tortoise = $this->head;

        while ($tortoise !== null) {
            $hare = $tortoise;
            while ($hare->getNext() !== null) {
                if (Comparator::equals($hare->getNext()->getValue(), $tortoise->getValue())) {
                    $hare->setNext($hare->getNext()->getNext());
                } else {
                    $hare = $hare->getNext();
                }
            }
            $tortoise = $tortoise->getNext();
        }
    }
303895
def duplicate(self):
        '''
        
        '''
        instance = self.__class__(name=self.name, description=self.description)
        for line in self.lines:
            instance.lines.append(line.duplicate())
        return instance
1104590
def duplicates(inlist):
    
    dups = []
    for i in range(len(inlist)):
        if inlist[i] in inlist[i+1:]:
            dups.append(inlist[i])
    return dups
136553
protected function _next()
    {
        try {
            $this->_setIteration($this->_loop());
        } catch (RootException $exception) {
            $this->_throwIteratorException(
                $this->__('An error occurred while iterating'),
                null,
                $exception
            );
        }
    }
779845
def remove_first(self):
        

        if self.head is None:
            return False

        self.head = self.head.next_node
        return True
815700
public U duplicateStream(boolean lastStream) {
        if (!processor.isDuplicable()) {
            throw new IllegalStateException("duplicator is closed or last downstream is added.");
        }
        return doDuplicateStream(new ChildStreamMessage<>(this, processor, lastStream));
    }
1113062
def from_list(lst):
        
        if not lst:
            return None

        head = Node(lst[0], None)

        if len(lst) == 1:
            return head

        head.next_node = LinkedList.from_list(lst[1:])
        return 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);
        }
    }
1280111
@Override
    public void dup()
    {
        if (top < 1)
        {
            throw new EmptyStackException();
        }
        if (top >= stack.length)
        {
            stack = Arrays.copyOf(stack, (int) (stack.length*growFactor));
        }
        top++;
        stack[top-1] = stack[top-2];
    }
435242
@Override
    public HistogramIterationValue next() {
        // Move through the sub buckets and buckets until we hit the next reporting level:
        while (!exhaustedSubBuckets()) {
            countAtThisValue = histogram.getCountAtIndex(currentIndex);
            if (freshSubBucket) { // Don't add unless we've incremented since last bucket...
                totalCountToCurrentIndex += countAtThisValue;
                totalValueToCurrentIndex += countAtThisValue * histogram.highestEquivalentValue(currentValueAtIndex);
                freshSubBucket = false;
            }
            if (reachedIterationLevel()) {
                long valueIteratedTo = getValueIteratedTo();
                currentIterationValue.set(valueIteratedTo, prevValueIteratedTo, countAtThisValue,
                        (totalCountToCurrentIndex - totalCountToPrevIndex), totalCountToCurrentIndex,
                        totalValueToCurrentIndex, ((100.0 * totalCountToCurrentIndex) / arrayTotalCount),
                        getPercentileIteratedTo(), integerToDoubleValueConversionRatio);
                prevValueIteratedTo = valueIteratedTo;
                totalCountToPrevIndex = totalCountToCurrentIndex;
                // move the next iteration level forward:
                incrementIterationLevel();
                if (histogram.getTotalCount() != savedHistogramTotalRawCount) {
                    throw new ConcurrentModificationException();
                }
                return currentIterationValue;
            }
            incrementSubBucket();
        }
        // Should not reach here. But possible for overflowed histograms under certain conditions
        throw new ArrayIndexOutOfBoundsException();
    }
355854
public void calcOccurrences() {
        State state;
        Iterator iter;
        boolean changes;

        iter = states.iterator();
        while (iter.hasNext()) {
            state = (State) iter.next();
            state.minOcc = 1;
            state.maxOcc = 1;
        }
        do {
            // TODO: iterating in reverse order might be faster
            changes = false;
            iter = states.iterator();
            while (iter.hasNext()) {
                state = (State) iter.next();
                if (state.recalcOccurrence(this)) {
                    changes = true;
                }
            }
        } while (changes);
    }
910188
def _deduplicate(lst):
    """"""
    out = []
    for i in lst:
        if i not in out:
            out.append(i)
    return out
1014644
private boolean next() throws IOException {
    if (valuesRead >= endOfPageValueCount) {
      if (valuesRead >= totalValueCount) {
        // How do we get here? Throw end of stream exception?
        return false;
      }
      readPage();
    }
    ++valuesRead;
    // TODO: Don't read for flat schemas
    //repetitionLevel = repetitionLevelColumn.nextInt();
    return definitionLevelColumn.nextInt() == maxDefLevel;
  }
560431
private void iterateGroupNodes(long groupdId, NodeReader nodeReader)
    {
        // while the index can be a long, the value is always an int
        int currentPointer = (int) headPointers.get(groupdId);
        checkArgument(currentPointer != NULL, "valid group must have non-null head pointer");

        while (currentPointer != NULL) {
            checkState(currentPointer < nextNodePointer, "error, corrupt pointer; max valid %s, found %s", nextNodePointer, currentPointer);
            nodeReader.read(currentPointer);
            currentPointer = nextPointers.get(currentPointer);
        }
    }
1187910
@Override
	public void set(final Iterator<Tuple2<KEY, VALUE>> iterator) {
		this.iterator = iterator;
		if (this.hasNext()) {
			final Tuple2<KEY, VALUE> tuple = iterator.next();
			this.curKey = keySerializer.copy(tuple.f0);
			this.firstValue = tuple.f1;
			this.atFirst = true;
		} else {
			this.atFirst = false;
		}
	}
1144003
def _repeat(self, index, stage, stop):
        
        times = None
        if 'iterations' in stage.kwargs:
            times = stage.kwargs['iterations'] - 1
        stages_back = 1
        if 'stages' in stage.kwargs:
            stages_back = stage.kwargs['stages']
        i = 0
        while i != times:
            if stop.is_set():
                break
            for forward in range(stages_back):
                if stop.is_set():
                    break
                stage_index = index - stages_back + forward
                self._execute_stage(stage_index, self._pipe[stage_index], stop)
            i += 1
1002829
Node<E> first() {
        restartFromHead:
        for (;;)
            for (Node<E> h = head, p = h, q;;) {
                if ((q = p.prev) != null &&
                    (q = (p = q).prev) != null)
                    // Check for head updates every other hop.
                    // If p == q, we are sure to follow head instead.
                    p = (h != (h = head)) ? h : q;
                else if (p == h
                         // It is possible that p is PREV_TERMINATOR,
                         // but if so, the CAS is guaranteed to fail.
                         || HEAD.compareAndSet(this, h, p))
                    return p;
                else
                    continue restartFromHead;
            }
    }