code: public static <K, V, E> Map<K, V> collectEntries(Iterable<E> self, Map<K, V> collector, @ClosureParams(FirstParam.FirstGenericType.class) Closure<?> transform) {
          return collectEntries(self.iterator(), collector, transform);
      }
docs: Iterates through this Iterable transforming each item using the closure
  as a transformer into a map entry, returning the supplied map with all of the transformed entries added to it.
  <pre class="groovyTestCase">
  def letters = "abc"
  // collect letters with index
  assert (0..2).collectEntries( [:] ) { index {@code ->} [index, letters[index]] } == [0:'a', 1:'b', 2:'c']
  assert (0..2).collectEntries( [4:'d'] ) { index {@code ->}
  [(index+1): letters[index]] } == [1:'a', 2:'b', 3:'c', 4:'d']
  </pre>
  Note: When using the list-style of result, the behavior is '<code>def (key, value) = listResultFromClosure</code>'.
  While we strongly discourage using a list of size other than 2, Groovy's normal semantics apply in this case;
  throwing away elements after the second one and using null for the key or value for the case of a shortened list.
  If your collector Map doesn't support null keys or values, you might get a runtime error, e.g. NullPointerException or IllegalArgumentException.
  
  @param self      an Iterable
  @param collector the Map into which the transformed entries are put
  @param transform the closure used for transforming, which has an item from self as the parameter and
  should return a Map.Entry, a Map or a two-element list containing the resulting key and value
  @return the collector with all transformed values added to it
  @see #collectEntries(Iterator, Map, Closure)
  @since 1.8.7