code: public static <K, V> Map<K, V> eachWithIndex(Map<K, V> self, @ClosureParams(value=MapEntryOrKeyValue.class, options="index=true") Closure closure) {
          int counter = 0;
          for (Map.Entry entry : self.entrySet()) {
              callClosureForMapEntryAndCounter(closure, entry, counter++);
          }
          return self;
      }
docs: Allows a Map to be iterated through using a closure. If the
  closure takes two parameters then it will be passed the Map.Entry and
  the item's index (a counter starting at zero) otherwise if the closure
  takes three parameters then it will be passed the key, the value, and
  the index.
  <pre class="groovyTestCase">def result = ""
  [a:1, b:3].eachWithIndex { key, value, index {@code ->} result += "$index($key$value)" }
  assert result == "0(a1)1(b3)"</pre>
  <pre class="groovyTestCase">def result = ""
  [a:1, b:3].eachWithIndex { entry, index {@code ->} result += "$index($entry)" }
  assert result == "0(a=1)1(b=3)"</pre>
  
  @param self    the map over which we iterate
  @param closure a 2 or 3 arg Closure to operate on each item
  @return the self Object
  @since 1.5.0