Get an Iterator that returns the same elements returned by the supplied Iterator, but in a
completely random order.
975873
public static <T> Iterator<T> getRandomIterator (Iterator<T> itr)
    {
        ArrayList<T> list = new ArrayList<T>();
        CollectionUtil.addAll(list, itr);
        java.util.Collections.shuffle(list);
        return getUnmodifiableIterator(list);
    }
1084387
def random_combination(iterable, r):
    ""
    pool = tuple(iterable)
    n = len(pool)
    indices = sorted(random.sample(xrange(n), r))
    return tuple(pool[i] for i in indices)
531661
public static <E> Iterator<E> asIterator(Enumeration<E> e) {
		return IterUtil.asIterator(e);
	}
231430
public static <E> ImmutableList<E> shuffledCopy(List<? extends E> list, Random rng) {
    final ArrayList<E> shuffled = Lists.newArrayList(list);
    Collections.shuffle(shuffled, rng);
    return ImmutableList.copyOf(shuffled);
  }
188772
def copy_iterator(self):
        
        self.__udiff, iterator_copy = itertools.tee(self.__udiff)
        return iterator_copy
70960
public static <T> Iterator<T> distinct(final Iterator<T> iterator) {
        requireNonNull(iterator);
        return new AbstractIterator<T>() {
            private final PeekingIterator<T> peekingIterator = peekingIterator(iterator);
            private T curr = null;

            @Override
            protected T computeNext() {
                while (peekingIterator.hasNext() && Objects.equals(curr, peekingIterator.peek())) {
                    peekingIterator.next();
                }
                if (!peekingIterator.hasNext())
                    return endOfData();

                curr = peekingIterator.next();
                return curr;
            }
        };
    }
877883
def generator(self, random, args):
        """"""
        locations = [i for i in range(len(self.weights))]
        random.shuffle(locations)
        return locations
141221
def uniform_iterator(sequence):
    """"""

    if isinstance(sequence, abc.Mapping):
        return six.iteritems(sequence)
    else:
        return enumerate(sequence)
797082
public static <T> Iterator<T> getSortedIterator (Iterator<T> itr, Comparator<T> comparator)
    {
        SortableArrayList<T> list = new SortableArrayList<T>();
        CollectionUtil.addAll(list, itr);
        list.sort(comparator);
        return getUnmodifiableIterator(list);
    }
578048
public static <E> E first(Iterator<E> iterator) {
        return new FirstElement<E>().apply(iterator);
    }
947864
public static <E> Iterable<E> asIterable(final Iterator<E> iter) {
		return new Iterable<E>() {
			@Override
			public Iterator<E> iterator() {
				return iter;
			}
		};
	}
1041463
def get_random_item(enum: Any, rnd: Optional[Random] = None) -> Any:
    
    if rnd and isinstance(rnd, Random):
        return rnd.choice(list(enum))
    return random_module.choice(list(enum))
463307
def peekiter(iterable):
    """"""
    it = iter(iterable)
    one = next(it)

    def gen():
        """Generator that returns first and proxy other items from source"""
        yield one
        while True:
            yield next(it)
    return (one, gen())
528289
public Iterator<ISO9660Directory> sortedIterator() {
        if (sortedIterator == null) {
            sortedIterator = new ISO9660DirectoryIterator(this, true);
        }
        sortedIterator.reset();
        return sortedIterator;
    }
61984
public static <T> Iterator<T> reorderIf( RandSeq randSeq, Iterator<T> sequence)
    {
    return randSeq==null? sequence : randSeq.reorder( sequence);
    }
1014291
public Iterator<T> iterator() {

        if (input == null)
            return null;

        if (outputIterator == null)
            outputIterator = new SinkIterator<T>(input.iterator());

        return outputIterator;
    }
628060
public <T> T randomElement(List<T> elements) {
		return elements.get(randomBetween(0, elements.size() - 1));
	}