recursively find the references in an iterable
511933
private void findReferencesIterable(SerIterator itemIterator, Map<Object, Integer> objects) {
        if (itemIterator.category() == SerCategory.MAP) {
            while (itemIterator.hasNext()) {
                itemIterator.next();
                findReferencesBean(itemIterator.key(), itemIterator.keyType(), objects, null);
                findReferencesBean(itemIterator.value(), itemIterator.valueType(), objects, itemIterator);
            }
        } else if (itemIterator.category() == SerCategory.COUNTED) {
            while (itemIterator.hasNext()) {
                itemIterator.next();
                findReferencesBean(itemIterator.value(), itemIterator.valueType(), objects, itemIterator);
            }
        } else if (itemIterator.category() == SerCategory.TABLE) {
            while (itemIterator.hasNext()) {
                itemIterator.next();
                findReferencesBean(itemIterator.key(), itemIterator.keyType(), objects, null);
                findReferencesBean(itemIterator.column(), itemIterator.columnType(), objects, null);
                findReferencesBean(itemIterator.value(), itemIterator.valueType(), objects, itemIterator);
            }
        } else if (itemIterator.category() == SerCategory.GRID) {
            while (itemIterator.hasNext()) {
                itemIterator.next();
                findReferencesBean(itemIterator.value(), itemIterator.valueType(), objects, itemIterator);
            }
        } else {
            while (itemIterator.hasNext()) {
                itemIterator.next();
                findReferencesBean(itemIterator.value(), itemIterator.valueType(), objects, itemIterator);
            }
        }
    }
261580
function each (iterable, fn) {
        var len
            , i = 0
            , iter
            , item
            , ret
        ;

        if (!iterable) throw genTypeError($invalidArgument);

        var gen = iterable[Symbol[$iterator]];
        if (isFunction(gen))
            iter = gen.call(iterable);
        else if (isFunction(iterable.next)) {
            iter = iterable;
        }
        else if (isInstanceOf(iterable, Arr)) {
            len = iterable.length;
            while (i < len) {
                fn(iterable[i], i++);
            }
            return i;
        } else
            throw genTypeError($invalidArgument);

        while (!(item = iter.next()).done) {
            ret = genTryCatcher(fn)(item.value, i++);
            if (ret === $tryErr) {
                isFunction(iter[$return]) && iter[$return]();
                throw ret.e;
            }
        }

        return i;
    }
306189
def iflatten(L):
    """"""
    for sublist in L:
        if hasattr(sublist, '__iter__'):
            for item in iflatten(sublist): yield item
        else: yield sublist
1033480
private void findReferencesBean(
            Object base,
            Class<?> declaredClass,
            Map<Object, Integer> objects,
            SerIterator parentIterator) {

        if (base == null) {
            return;
        }

        // has this object been seen before, if so no need to check it again
        int result = objects.compute(base, BeanReferences::incrementOrOne);
        if (result > 1) {
            return;
        }

        if (base instanceof Bean) {
            addClassInfo(base, declaredClass);
            Bean bean = (Bean) base;
            if (settings.getConverter().isConvertible(bean.getClass())) {
                return;
            }

            for (MetaProperty<?> prop : bean.metaBean().metaPropertyIterable()) {
                if (settings.isSerialized(prop)) {
                    Object value = prop.get(bean);
                    Class<?> type = SerOptional.extractType(prop, base.getClass());

                    if (value != null) {
                        SerIterator itemIterator = settings.getIteratorFactory().create(value, prop, bean.getClass());
                        if (itemIterator != null) {
                            if (itemIterator.metaTypeRequired()) {
                                objects.compute(itemIterator.metaTypeName(), BeanReferences::incrementOrOne);
                            }
                            findReferencesIterable(itemIterator, objects);
                        } else {
                            findReferencesBean(value, type, objects, null);
                        }
                    } else {
                        // In case it's a null value or optional field
                        addClassInfo(type, type);
                    }
                }
            }
        } else if (parentIterator != null) {
            SerIterator childIterator = settings.getIteratorFactory().createChild(base, parentIterator);
            if (childIterator != null) {
                findReferencesIterable(childIterator, objects);
            } else {
                addClassInfo(base, declaredClass);
            }
        } else {
            addClassInfo(base, declaredClass);
        }
    }
1266254
def this_and_prev(iterable):
    """"""
    try:
        item = next(iterable)
        while True:
            next_item = next(iterable)
            yield item, next_item
            item = next_item
    except StopIteration:
        return
255121
def recursive(self):
        
        for m in self.members.values():
            if m.kind is not None and m.kind.lower() == self.name.lower():
                return True
        else:
            return False
868645
private Iterable<String> getAllIncluding(String index, Iterable<String> keys, IterableChain<String> result) {
        result.addAll(keys);
        for (String key : keys) {
            Iterable<String> values = get(index, key);
            if (values.iterator().hasNext()) {
                getAllIncluding(index, values, result);
            }
        }
        return result;
    }
372960
def itertypes(iterable):
    """"""
    seen = set()
    for entry in iterable:
        if isinstance(entry, tuple):
            for type_ in entry:
                if type_ not in seen:
                    seen.add(type_)
                    yield type_
        else:
            if entry not in seen:
                seen.add(entry)
                yield entry
735510
def peek_at(iterable: Iterable[T]) -> Tuple[T, Iterator[T]]:
    
    gen = iter(iterable)
    peek = next(gen)
    return peek, itertools.chain([peek], gen)
633809
@SafeVarargs
    @SuppressWarnings("unchecked")
    public static <T> Iterable<T> compositeIterable(Iterable<T>...iterables) {
        Require.nonNull(iterables, "iterables");
        final Iterator<T> it;
        if (iterables.length == 0) {
            it = Collections.emptyIterator();
        } else if (iterables.length == 1) {
            return iterables[0];
        } else {
            final Iterator<T>[] iterators = Arrays.stream(iterables)
                    .map(Iterable::iterator)
                    .toArray(size -> new Iterator[size]);
            it = new CompoundIterator<T>(iterators);
        }
        return iterableOf(it);
    }
662337
public static <T> List<T> list(boolean isLinked, Iterable<T> iterable) {
		if (null == iterable) {
			return list(isLinked);
		}
		return list(isLinked, iterable.iterator());
	}
1354269
private Collection<? extends String> recursiveCollect(String refId,
      Map<String, SortedSet<String>> relationKeyMap, int maxRecursion) {
    Set<String> list = new HashSet<>();
    if (maxRecursion > 0 && relationKeyMap.containsKey(refId)) {
      SortedSet<String> subList = relationKeyMap.get(refId);
      for (String subRefId : subList) {
        list.add(subRefId);
        list.addAll(
            recursiveCollect(subRefId, relationKeyMap, maxRecursion - 1));
      }
    }
    return list;
  }
1204569
def children( record, index, key='refs', stop_types=STOP_TYPES ):
    """"""
    result = []
    for ref in record.get( key,[]):
        try:
            record = index[ref]
        except KeyError, err:
            #print 'No record for %s address %s in %s'%(key, ref, record['address'] )
            pass # happens when an unreachable references a reachable that has been compressed out...
        else:
            if record['type'] not in stop_types:
                result.append(  record  )
    return result
269669
@Override
    public <R> ListT<W,R> unitIterable(final Iterable<R> it) {
        return of(run.unitIterable(it)
                     .map(i -> ListX.of(i)));
    }
926767
def gather(self, iterable):
        
        for result in self.lookup(iterable, gather=True):
            yield result
986968
def tree_iterator(self, visited=None, path=None):
        '''
        
        '''
        if visited is None:
            visited = set()

        if self not in visited:
            if path and isinstance(path, list):
                path.append(self)

            visited.add(self)
            yield self

            if not hasattr(self, 'dterms'):
                yield

            for dterm in self.dterms:
                if hasattr(self, dterm):
                    child = getattr(self, dterm)
                    if hasattr(child, 'dterms') or hasattr(child, 'terms'):
                        for node in child.tree_iterator(visited):
                            yield node
1191435
def items(iterable):
    
    if hasattr(iterable, 'iteritems'):
        return (p for p in iterable.iteritems())
    elif hasattr(iterable, 'items'):
        return (p for p in iterable.items())
    else:
        return (p for p in enumerate(iterable))