package gw.util uses java.util.Map @ReadOnly enhancement ArrayCoreEnhancement : T[] { /** * 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 { return this.toList().mapToValue(mapper) } /** * 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 { return this.toList().mapToKeyAndValue(getKey, getValue) } /** * Returns array with the first {@code number} items of this array. */ function limit(number: int): T[] { if (this.Count <= number) { return this } return Arrays.copyOf(this, number) } }