package gw.util uses com.google.common.collect.Iterables uses java.lang.Iterable uses java.util.Map @ReadOnly enhancement IterableCoreEnhancement : Iterable { /** * Returns a map containing key value pairs from each element to the result of calling mapper on each * element. This method is the inverse of partitionUniquely(). */ public function mapToValue(mapper(elt : T) : V) : Map { var map : Map = {} this.each(\ elt -> map.put(elt, mapper(elt))) return map } /** * Returns a map containing key value pairs from the result of calling getKey on each element to the * result of calling getValue on each element. */ public function mapToKeyAndValue(getKey(elt : T) : K, getValue(elt : T) : V) : Map { var map : Map = {} this.each(\ elt -> map.put(getKey(elt), getValue(elt))) return map } /** * Returns Iterable with the first {@code number} items of this Iterable. */ function limit(number: int): Iterable { return Iterables.limit(this, number) } }