Calculate various forms of derivatives in order to reduce data entropy.

@param map attributes
@param sortVertices sorted vertices
@return encoded UV data
16616
private int[] makeUVCoordDeltas(AttributeData map, SortableVertex[] sortVertices) {
        // UV coordinate scaling factor
        float scale = 1.0f / map.precision;
        int vc = sortVertices.length;
        int prevU = 0, prevV = 0;
        int[] intUVCoords = new int[vc * CTM_UV_ELEMENT_COUNT];
        for (int i = 0; i < vc; ++i) {
            // Get old UV coordinate index (before vertex sorting)
            int oldIdx = sortVertices[i].originalIndex;

            // Convert to fixed point
            int u = (int) floor(scale * map.values[oldIdx * 2] + 0.5f);
            int v = (int) floor(scale * map.values[oldIdx * 2 + 1] + 0.5f);

            // Calculate delta and store it in the converted array. NOTE: Here we rely
            // on the fact that vertices are sorted, and usually close to each other,
            // which means that UV coordinates should also be close to each other...
            intUVCoords[i * 2] = u - prevU;
            intUVCoords[i * 2 + 1] = v - prevV;

            prevU = u;
            prevV = v;
        }
        return intUVCoords;
    }
1061472
public static Map<String, ?> redactValues(Map<String, ?> map) {
        Map<String, Object> result = new LinkedHashMap<String, Object>();
        result.putAll(map);
        for (String key : map.keySet()) {
            Object value = map.get(key);
            if (value == null) {
                result.put(key, value);
             } else if (value instanceof Map) {
                @SuppressWarnings("unchecked")
                Map<String, ?> bare = (Map<String, ?>) value;
                result.put(key, redactValues(bare));
            } else if (value instanceof String && StringUtils.isEmpty(value)){
                result.put(key, "");
            } else {
                result.put(key, "<redacted>");
            }
        }
        return result;
    }
21177
public static IntMultimap invertFrom(Multimap<? extends Integer, ? extends Integer> map) {
    if (map instanceof IntMultimap) {
      IntMultimap other = (IntMultimap) map;
      // This is unnecessary, but it makes this method easier to implement.
      other.reindexItems();

      int[] newSortedKeys = Arrays.copyOf(other.sortedValues, other.sortedValues.length);
      int[] newSortedValues = Arrays.copyOf(other.sortedKeys, other.sortedKeys.length);
     
      ArrayUtils.sortKeyValuePairs(newSortedKeys, newSortedValues, 0, newSortedKeys.length);

      return new IntMultimap(newSortedKeys, newSortedValues);
    } else {
      IntMultimap inverse = IntMultimap.create();
      Multimaps.invertFrom(map, inverse);
      return inverse;
    }
  }
888632
private static Double max(Map<String, Double> map)
    {
        Double theMax = 0.0;
        for (Double v : map.values())
        {
            theMax = Math.max(theMax, v);
        }

        return theMax;
    }
627531
private int[] makeAttribDeltas(AttributeData map, SortableVertex[] sortVertices) {
        // Attribute scaling factor
        float scale = 1.0f / map.precision;

        int[] prev = new int[4];

        int vc = sortVertices.length;
        int[] intAttribs = new int[vc * CTM_ATTR_ELEMENT_COUNT];

        for (int i = 0; i < vc; ++i) {
            // Get old attribute index (before vertex sorting)
            int oldIdx = sortVertices[i].originalIndex;

            // Convert to fixed point, and calculate delta and store it in the converted
            // array. NOTE: Here we rely on the fact that vertices are sorted, and
            // usually close to each other, which means that attributes should also
            // be close to each other (and we assume that they somehow vary slowly with
            // the geometry)...

            for (int j = 0; j < 4; ++j) {
                int value = (int) floor(scale * map.values[oldIdx * 4 + j] + 0.5f);
                intAttribs[i * 4 + j] = value - prev[j];
                prev[j] = value;
            }
        }
        return intAttribs;
    }
555162
public static <K extends Comparable<? super K>, V> List<Map.Entry<K, V>> sortedEntries(Map<K, V> map) {
    return sortedEntries(map.entrySet());
  }
451500
protected void sortIndexMap() {
        for (Iterator<List<Doc>> it = indexmap.values().iterator(); it.hasNext(); ) {
            Collections.sort(it.next(), new DocComparator());
        }
    }
127079
private static Map<String,String> getRankMap(Object[] params){
        if (params == null) {
            return null;
        }
        HashMap<String,String> result = new HashMap<>();
        for (int i = 0; i < params.length; i++) {
            String name = params[i] instanceof Parameter ?
                ((Parameter) params[i]).name() :
                ((TypeVariable) params[i]).typeName();
            result.put(name, String.valueOf(i));
        }
        return result;
    }
906825
private static Map<String, String> getRankMap(Utils utils, List<? extends Element> params){
        if (params == null) {
            return null;
        }
        HashMap<String, String> result = new HashMap<>();
        int rank = 0;
        for (Element e : params) {
            String name = utils.isTypeParameterElement(e)
                    ? utils.getTypeName(e.asType(), false)
                    : utils.getSimpleName(e);
            result.put(name, String.valueOf(rank));
            rank++;
        }
        return result;
    }
1313830
public static <K, V> Map<K, V> sortNumberMapByKeyDescending(Map<K, V> map) {
        return sortNumberMapByKeyDescending(map.entrySet());
    }
1207225
private SortedMap<String, SortedSet<ITestNGMethod>> sortGroups(Map<String, Collection<ITestNGMethod>> groups)
    {
        SortedMap<String, SortedSet<ITestNGMethod>> sortedGroups = new TreeMap<String, SortedSet<ITestNGMethod>>();
        for (Map.Entry<String, Collection<ITestNGMethod>> entry : groups.entrySet())
        {
            SortedSet<ITestNGMethod> methods = new TreeSet<ITestNGMethod>(METHOD_COMPARATOR);
            methods.addAll(entry.getValue());
            sortedGroups.put(entry.getKey(), methods);
        }
        return sortedGroups;
    }
202837
@Override
  public SortedMap<Double, Set<String>> sortedScoreMap(String[] text) {
    SortedMap<Double, Set<String>> descendingMap = new TreeMap<>();
    double[] categorize = classifyProb(text);
    int catSize = getNumberOfLabels();
    for (int i = 0; i < catSize; i++) {
      String category = getLabel(i);
      double score = categorize[getIndex(category)];
      if (descendingMap.containsKey(score)) {
        descendingMap.get(score).add(category);
      } else {
        Set<String> newset = new HashSet<>();
        newset.add(category);
        descendingMap.put(score, newset);
      }
    }
    return descendingMap;
  }
537054
public static SortedMap<Short, List<MappeableContainer>> groupByKey(
          ImmutableRoaringBitmap... bitmaps) {
    Map<Short, List<MappeableContainer>> grouped = new HashMap<>();
    for (ImmutableRoaringBitmap bitmap : bitmaps) {
      MappeableContainerPointer it = bitmap.highLowContainer.getContainerPointer();
      while (null != it.getContainer()) {
        MappeableContainer container = it.getContainer();
        Short key = it.key();
        List<MappeableContainer> slice = grouped.get(key);
        if (null == slice) {
          slice = new ArrayList<>();
          grouped.put(key, slice);
        }
        slice.add(container);
        it.advance();
      }
    }
    SortedMap<Short, List<MappeableContainer>> sorted = new TreeMap<>(BufferUtil::compareUnsigned);
    sorted.putAll(grouped);
    return sorted;
  }
120306
public static long[] sortAndFilterThreadIdsByValue(LongObjectMap map, int threadLimit) {
		int max = Math.min(threadLimit, map.size());
		List<Map.Entry> list = new LinkedList(map.entrySet());
		Collections.sort(list, new Comparator() {
			@Override
			public int compare(Object o1, Object o2) {
				return ((Comparable) ((Map.Entry) (o2)).getValue()).compareTo(((Map.Entry) (o1)).getValue());
			}
		});

		long[] topTidArray = new long[max];
		int i = 0;
		for (Map.Entry entry : list) {
			topTidArray[i] = (Long) entry.getKey();
			if (++i >= max) {
				break;
			}
		}

		return topTidArray;
	}
865483
public static <K, V extends Comparable> SortedSetMultimap<K, V> createSortedSetMultiValueMap() {
		return MultimapBuilder.hashKeys().treeSetValues().build();
	}
747964
public static <K, V> SortedMap<K, V> nullToEmpty(final SortedMap<K, V> map) {
        return map == null ? N.<K, V> emptySortedMap() : map;
    }
1041305
public static Graph sortDFS(Graph g, Graph sortedGraph) {
        int nodes = g.getNodes();
        final GHIntArrayList list = new GHIntArrayList(nodes);
        list.fill(nodes, -1);
        final GHBitSetImpl bitset = new GHBitSetImpl(nodes);
        final AtomicInteger ref = new AtomicInteger(-1);
        EdgeExplorer explorer = g.createEdgeExplorer();
        for (int startNode = 0; startNode >= 0 && startNode < nodes;
             startNode = bitset.nextClear(startNode + 1)) {
            new DepthFirstSearch() {
                @Override
                protected GHBitSet createBitSet() {
                    return bitset;
                }

                @Override
                protected boolean goFurther(int nodeId) {
                    list.set(nodeId, ref.incrementAndGet());
                    return super.goFurther(nodeId);
                }
            }.start(explorer, startNode);
        }
        return createSortedGraph(g, sortedGraph, list);
    }