An Iterable may be a list or a generator.
    This ensures we get a list without making an unnecessary copy.
760246
def ensure_list(iterable: Iterable[A]) -> List[A]:
    
    if isinstance(iterable, list):
        return iterable
    else:
        return list(iterable)
785931
def _extract_list_from_generator(generator):
    

    extracted = []
    for i in generator:
        extracted.append(list(i))
    return extracted
847215
def multi_iter(iterable, count=2):
    """"""
    # no need to special-case re-usable, container-like iterables
    if not isinstance(
            iterable,
            (
                    list, tuple, set,
                    FutureChainResults,
                    collections.Sequence, collections.Set, collections.Mapping, collections.MappingView
            )):
        iterable = SafeTee(iterable, n=count)
    return (iter(iterable) for _ in range(count))
647040
@SuppressWarnings("unchecked")
	static <T> List<T> toList(final Iterable<? extends T> iterable)
	{
		if (iterable instanceof List)
		{
			return (List<T>) iterable;
		}
		return ImmutableList.copyOf(iterable);
	}
482292
def _iter_list_for_dicts(self, check_list):
        """"""

        list_copy = copy.deepcopy(check_list)
        for index, elem in enumerate(check_list):
            if isinstance(elem, dict):
                list_copy[index] = self._check_for_python_keywords(elem)
            elif isinstance(elem, list):
                list_copy[index] = self._iter_list_for_dicts(elem)
            else:
                list_copy[index] = elem
        return list_copy
1147613
def iter_non_intersecting(self, iterable, key=None, descending=False):
        
        return _ContainsVersionIterator(self, iterable, key, descending,
            mode=_ContainsVersionIterator.MODE_NON_INTERSECTING)
1004422
def extend(self, iterable):
        """"""
        return super(Collection, self).extend(
            self._ensure_iterable_is_valid(iterable))
396278
public static <T> ImmutableList<T> asUniquedList(Iterable<T> items) {
    return ImmutableSet.copyOf(items).asList();
  }
1005592
public static Predicates<Object> in(Iterable<?> iterable)
    {
        if (iterable instanceof SetIterable<?>)
        {
            return new InSetIterablePredicate((SetIterable<?>) iterable);
        }
        if (iterable instanceof Set<?>)
        {
            return new InSetPredicate((Set<?>) iterable);
        }
        if (iterable instanceof Collection<?> && ((Collection<?>) iterable).size() <= SMALL_COLLECTION_THRESHOLD)
        {
            return new InCollectionPredicate((Collection<?>) iterable);
        }
        return new InSetIterablePredicate(UnifiedSet.newSet(iterable));
    }
1161265
public static <T> Set<T> iterableToSet(Iterable<T> iterable) {
        if (iterable == null) {
            return Collections.emptySet();
        }
        if (iterable instanceof Set) {
            return (Set<T>) iterable;
        }
        Iterator<T> i = iterable.iterator();
        if (i.hasNext()) {
            Set<T> list = new HashSet<>();
            while (i.hasNext()) {
                list.add(i.next());
            }
            return list;
        }
        return Collections.emptySet();
    }
465462
public static <T> Iterator<T> iteratorOverIterables(
        Iterable<? extends T> iterable0, Iterable<? extends T> iterable1)
    {
        Objects.requireNonNull(iterable0, "The iterable0 is null");
        Objects.requireNonNull(iterable1, "The iterable1 is null");
        List<Iterable<? extends T>> iterables =
            new ArrayList<Iterable<? extends T>>(2);
        iterables.add(iterable0);
        iterables.add(iterable1);
        return iteratorOverIterables(iterables.iterator());
    }
368583
def unique(iterable):
    """"""
    seen = set()
    for item in iterable:
        if item not in seen:
            seen.add(item)
            yield item
703932
def is_iterable_of_int(l):
     """
    if not is_iterable(l):
        return False

    return all(is_int(value) for value in l)
104066
public static <T> Set<T> toSet(Iterable<T> iterable)
   {
      if (iterable == null)
      {
         return null;
      }
      else if (iterable instanceof Set)
      {
         return (Set<T>) iterable;
      }
      else
      {
         Set<T> list = new LinkedHashSet<>();
         for (T obj : iterable)
         {
            list.add(obj);
         }
         return list;
      }
   }
911090
@SuppressWarnings("unchecked")
  public static Iterator<Object> iterator(Object iterable) {
    Assert.state(isIterable(iterable.getClass()));
    return iterable.getClass().isArray() ? new ArrayIterator(iterable)
        : ((Iterable<Object>) iterable).iterator();
  }
1203998
def iterable(target):
    '''  '''
    if any(i in ('next', '__next__', '__iter__') for i in dir(target)):
        return True
    else:
        try:
            iter(target)
            return True
        except:
            return False
960518
def uniqued(iterable):
    
    seen = set()
    return [item for item in iterable if item not in seen and not seen.add(item)]