code: public static <K, V> Map<K, V> take(Map<K, V> self, int num) {
          if (self.isEmpty() || num <= 0) {
              return createSimilarMap(self);
          }
          Map<K, V> ret = createSimilarMap(self);
          for (K key : self.keySet()) {
              ret.put(key, self.get(key));
              if (--num <= 0) {
                  break;
              }
          }
          return ret;
      }
docs: Returns a new map containing the first <code>num</code> elements from the head of this map.
  If the map instance does not have ordered keys, then this function could return a random <code>num</code>
  entries. Groovy by default uses LinkedHashMap, so this shouldn't be an issue in the main.
  <pre class="groovyTestCase">
  def strings = [ 'a':10, 'b':20, 'c':30 ]
  assert strings.take( 0 ) == [:]
  assert strings.take( 2 ) == [ 'a':10, 'b':20 ]
  assert strings.take( 5 ) == [ 'a':10, 'b':20, 'c':30 ]
  </pre>
  
  @param self the original map
  @param num  the number of elements to take from this map
  @return a new map consisting of the first <code>num</code> elements of this map,
  or else the whole map if it has less then <code>num</code> elements.
  @since 1.8.1