对一个Map按Value进行排序，返回排序LinkedHashMap，最多只返回n条，多用于Value是Counter的情况.
@param reverse 按Value的倒序 or 正序排列
178429
public static <K, V extends Comparable> Map<K, V> topNByValue(Map<K, V> map, final boolean reverse, int n) {
		return topNByValueInternal(map, n, reverse ? Ordering.from(new ComparableEntryValueComparator<K, V>()).reverse()
				: new ComparableEntryValueComparator<K, V>());
	}
603658
public Map<Integer, Integer> getReverseNumericMap()
    {
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int newIndex = 0; newIndex < numIndexMap.length; newIndex++)
            map.put(newIndex, numIndexMap[newIndex]);
        return map;
    }
394000
public static <K> Map<K, Integer> rankMapOnIntegerValue(Map<K, Integer> inputMap) {
    Map<K, Integer> newMap = new TreeMap<K, Integer>(new IntegerValueComparator(inputMap));
    newMap.putAll(inputMap);

    Map<K, Integer> linkedMap = new LinkedHashMap<K, Integer>(newMap);
    return linkedMap;
  }
1288595
public void map(I item, T target)
    {
        mapSet.add(item, target);
        reverseMap.add(target, item);
    }
1113082
public LdiStringBuilder reverse() {
        int j = count - 1;
        for (int i = 0; i < j; ++i, --j) {
            final char temp = value[i];
            value[i] = value[j];
            value[j] = temp;
        }
        return this;
    }
195049
function n_reverse(list){var nl=arguments.length<=1||arguments[1]===undefined?null:arguments[1];//nl = nl || null;
if(!list)return nl;return n_reverse(n_tail(list),n_cons(n_head(list),nl));// simple tail recursion
}
1110864
public static <K, V> V putToConcurrentMap(ConcurrentMap<K, V> map, K key, V value) {
        V old = map.putIfAbsent(key, value);
        return old != null ? old : value;
    }
1157749
public Map<Integer, Integer> getReverseNominalMap()
    {
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int newIndex = 0; newIndex < catIndexMap.length; newIndex++)
            map.put(newIndex, catIndexMap[newIndex]);
        return map;
    }
419149
public static String rearstring(final String str, final int reverseIndex) {
        assertStringNotNull(str);
        if (str.length() < reverseIndex) {
            String msg = "The length of the string was smaller than the index:";
            msg = msg + " str=" + str + " reverseIndex=" + reverseIndex;
            throw new StringIndexOutOfBoundsException(msg);
        }
        return str.substring(str.length() - reverseIndex);
    }
1143426
private void reverse(byte[] buffer, int offset, int length) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "reverse", new Object[] { buffer, offset, length });

        byte temp;
        for (int i = 0; i < length / 2; i++) {
            temp = buffer[offset + i];
            buffer[offset + i] = buffer[offset + (length - 1) - i];
            buffer[offset + (length - 1) - i] = temp;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "reverse");
    }
99217
@Override protected void writeMap(AutoBuffer ab, int mode) {

    // For faster K/V store walking get the NBHM raw backing array,
    // and walk it directly.
    Object[] kvs = _map.raw_array();

    // Start the walk at slot 2, because slots 0,1 hold meta-data
    // In the raw backing array, Keys and Values alternate in slots
    // Ignore tombstones and Primes and null's
    switch( mode ) {
    case 1:  // <String,String>
      for( int i=2; i<kvs.length; i += 2 )
        if( kvs[i] instanceof String && kvs[i+1] instanceof String )
          ab.putStr((String)kvs[i]).putStr((String)kvs[i+1]);
      break;
    case 2: // <String,Freezable>
      for( int i=2; i<kvs.length; i += 2 )
        if( kvs[i] instanceof String && kvs[i+1] instanceof Iced   )
          ab.putStr((String)kvs[i]).put   ((Freezable)kvs[i+1]);
      break;
    case 3: // <Freezable,String>
      for( int i=2; i<kvs.length; i += 2 )
        if( kvs[i] instanceof Iced   && kvs[i+1] instanceof String )
          ab.put   ((Freezable  )kvs[i]).putStr((String)kvs[i+1]);
      break;
    case 4: // <Freezable,Freezable>
      for( int i=2; i<kvs.length; i += 2 )
        if( kvs[i] instanceof Freezable   && kvs[i+1] instanceof Freezable   )
          ab.put   ((Freezable  )kvs[i]).put   ((Freezable  )kvs[i+1]);
      break;
    case 5:  // <String,Freezable[]>
      for( int i=2;i<kvs.length; i+=2 )
        if( kvs[i] instanceof String && kvs[i+1] instanceof Freezable[] ) {
          Freezable[] vals = (Freezable[])kvs[i+1];
          ab.putStr((String)kvs[i]).put4(vals.length);  // key len vals
          for(Freezable v: vals) ab.put(v);
        }
      break;
    case 6: // <Freezable,Freezable[]>
      for( int i=2;i<kvs.length; i+=2 )
        if( kvs[i] instanceof Freezable && kvs[i+1] instanceof Freezable[] ) {
          Freezable[] vals = (Freezable[])kvs[i+1];
          ab.put((Freezable)kvs[i]).put4(vals.length);  // key len vals
          for(Freezable v: vals) ab.put(v);
        }
      break;
    default: throw H2O.fail();
    }
  }
304221
public Map<String, Set<String>> getReverseMap() {
    Set<Map.Entry<String,Set<String>>> entries = map.entrySet();
    Map<String, Set<String>> rMap = new HashMap<String, Set<String>>(entries.size());
    for (Map.Entry<String,Set<String>> me : entries) {
      String k = me.getKey();
      Set<String> transList = me.getValue();
      for (String trans : transList) {
        Set<String> entry = rMap.get(trans);
        if (entry == null) {
          // reduce default size as most will be small
          Set<String> toAdd = new LinkedHashSet<String>(6);
          toAdd.add(k);
          rMap.put(trans, toAdd);
        } else {
          entry.add(k);
        }
      }
    }
    return rMap;
  }
85756
public synchronized K reverseLookup(final V value) {
        if (tmap == null) {
            throw new IllegalStateException("not open");
        }
        return invTmap.findKeyForValue(value);
    }
1215542
@SuppressWarnings("unchecked")
    public void loopMap(final Object x, final MapIterCallback<K, V> callback) {
        if (x == null) {
            return;
        }

        if (x instanceof Collection) {
            throw new IllegalArgumentException("call loop instead");
        }

        if (x instanceof HashMap<?, ?>) {
            if (((HashMap) x).isEmpty()) {
                return;
            }

            final HashMap<?, ?> hm = (HashMap<?, ?>) x;
            for (final Entry<?, ?> e : hm.entrySet()) {
                callback.eval((K) e.getKey(), (V) e.getValue());
            }
            return;
        }
        if (x instanceof Map) {
            final Map<K, V> m = (Map<K, V>) x;
            for (final Entry<K, V> entry : m.entrySet()) {
                callback.eval(entry.getKey(), entry.getValue());
            }
            return;
        }
        if (x instanceof BSONObject) {
            final BSONObject m = (BSONObject) x;
            for (final String k : m.keySet()) {
                callback.eval((K) k, (V) m.get(k));
            }
        }

    }
776115
@Override
    public INDArray rot(INDArray reverse) {
        INDArray ret = Nd4j.create(reverse.shape());
        if (reverse.isVector())
            return reverse(reverse);
        else {
            for (int i = 0; i < reverse.slices(); i++) {
                ret.putSlice(i, reverse(reverse.slice(i)));
            }
        }
        return ret.reshape(reverse.shape());
    }
766479
public static <T> List<T> reverse(final Iterable<T> iterable) {
        final List<T> result = newArrayList(iterable);
        Collections.reverse(result);
        return result;
    }
1140448
public static NumberList delta(Map<String, Object> currentMap, Map<String, Object> previousMap) {
        LinkedHashMap<String, Long> values = new LinkedHashMap<String, Long>(currentMap.size());
        if(currentMap.size() != previousMap.size()) {
            throw new IllegalArgumentException("Maps must have the same keys");
        }
        for (Entry<String, Object> k : currentMap.entrySet()) {
            Object v = k.getValue();
            Number current = getNumber(v);
            Object p = previousMap.get(k.getKey());
            Number previous = null;
            if (p == null) {
                previous = 0;
            } else {
                previous = getNumber(p);
            }

            long d = (current.longValue() - previous.longValue());
            values.put(k.getKey(), d);
        }

        return new NumberList(values);
    }