Transforms an Iterable<T> to a Map<T, Integer> where each item is mapped to its zero-indexed
position(s) in the Iterable's sequence.
162673
public static <T> ImmutableMultimap<T, Integer> itemToIndexMultimap(
      Iterable<T> iterable) {
    final ImmutableMultimap.Builder<T, Integer> ret = ImmutableMultimap.builder();
    int idx = 0;
    for (final T x : iterable) {
      ret.put(x, idx++);
    }
    return ret.build();
  }
916496
@SuppressWarnings("unchecked")
    protected Iterable _transform(final Iterable iterable) {
        if (iterable == null) return null;
        if (iterable instanceof BeanIterable) return iterable;
        return new BeanIterable<>(iterable, this);
    }
276986
public static <T> Optional<Iterable<T>> convertCollection(Class<? extends Iterable<T>> iterableType, Collection<T> collection) {
        if (iterableType.isInstance(collection)) {
            return Optional.of(collection);
        }
        if (iterableType.equals(Set.class)) {
            return Optional.of(new HashSet<>(collection));
        }
        if (iterableType.equals(Queue.class)) {
            return Optional.of(new LinkedList<>(collection));
        }
        if (iterableType.equals(List.class)) {
            return Optional.of(new ArrayList<>(collection));
        }
        if (!iterableType.isInterface()) {
            try {
                Constructor<? extends Iterable<T>> constructor = iterableType.getConstructor(Collection.class);
                return Optional.of(constructor.newInstance(collection));
            } catch (Throwable e) {
                return Optional.empty();
            }
        }
        return Optional.empty();
    }
1274389
public static <K, V1, V2> Iterable<Map.Entry<K, V2>> transformEntries(
      Iterable<Map.Entry<K, V1>> input,
      final Maps.EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
    return Iterables.transform(input, new Function<Entry<K, V1>, Entry<K, V2>>() {
      @Override
      public Entry<K, V2> apply(final Entry<K, V1> input) {
        return Maps.immutableEntry(input.getKey(),
            entryTransformer.transformEntry(input.getKey(), input.getValue()));
      }
    });
  }
904776
private Map<String, ByteBuffer> tupleToKeyMap(Tuple t) throws IOException
    {
        Map<String, ByteBuffer> keys = new HashMap<String, ByteBuffer>();
        for (int i = 0; i < t.size(); i++)
        {
            if (t.getType(i) == DataType.TUPLE)
            {
                Tuple inner = (Tuple) t.get(i);
                if (inner.size() == 2)
                {
                    Object name = inner.get(0);
                    if (name != null)
                    {
                        keys.put(name.toString(), objToBB(inner.get(1)));
                    }
                    else
                        throw new IOException("Key name was empty");
                }
                else
                    throw new IOException("Keys were not in name and value pairs");
            }
            else
            {
                throw new IOException("keys was not a tuple");
            }
        }
        return keys;
    }
1016366
private static <E> Collection<E> toCollection(Iterable<E> iterable) {
		return (iterable instanceof Collection) ? (Collection<E>)iterable : Lists.newArrayList(iterable.iterator());
	}
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;
      }
   }
217547
public static <E> Iterable<E> cast(final Iterable i) {
        return map(i, new Mapper<Object, E>() {
                public E apply(Object o) {
                    return (E) o;
                }
            });
    }
107385
public static <T> Set<T> asSet(final Iterable<T> iterable)
   {
      Set<T> result = new HashSet<T>();
      for (T t : iterable)
      {
         result.add(t);
      }
      return result;
   }
1278439
function EnumMap(iter) {
    var p = {};
    priv.set(this, p);
    var newIter = iter;
    if(iter && typeof iter.entries === 'function') {
      if (iter instanceof EnumSet) {
        newIter = {
          entries: function() {
            var pi = priv.get(iter);
            return new Iterator(pi.sequence.sequence, 0);
          }
        };
      }
    }
    p.sequence = new Sequence(newIter);
  }
958354
def transform(self, callback):
        
        self._items = self.map(callback).all()

        return self
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());
    }
396278
public static <T> ImmutableList<T> asUniquedList(Iterable<T> items) {
    return ImmutableSet.copyOf(items).asList();
  }
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);
	}
207753
def recursive_map(func, data):
    
    def recurse(item):
        return recursive_map(func, item)
    items_mapped = map_collection(recurse, data)
    return func(items_mapped)
1230146
def flat_map(iterable, func):
    """"""
    results = []
    for element in iterable:
        result = func(element)
        if len(result) > 0:
            results.extend(result)
    return results
411709
static Iterable<ImmutableBitmap> bitmapsFromIndexes(final IntIterable indexes, final BitmapIndex bitmapIndex)
  {
    // Do not use Iterables.transform() to avoid boxing/unboxing integers.
    return new Iterable<ImmutableBitmap>()
    {
      @Override
      public Iterator<ImmutableBitmap> iterator()
      {
        final IntIterator iterator = indexes.iterator();

        return new Iterator<ImmutableBitmap>()
        {
          @Override
          public boolean hasNext()
          {
            return iterator.hasNext();
          }

          @Override
          public ImmutableBitmap next()
          {
            return bitmapIndex.getBitmap(iterator.nextInt());
          }

          @Override
          public void remove()
          {
            throw new UnsupportedOperationException();
          }
        };
      }
    };
  }