Helper function that handles creating the lower and upper bounds for calling {@link
SortedMap#subMap(Object, Object)}.

@see SortedMap#subMap(Object, Object)
837
private static <E> SortedMap<PrefixKey, E> getPrefixSubMap(
      TreeMap<PrefixKey, E> map, PrefixKey lowerBound) {
    PrefixKey upperBound =
        new PrefixKey(lowerBound.getBucket(), lowerBound.getObjectName() + Character.MAX_VALUE);
    return map.subMap(lowerBound, upperBound);
  }
1308096
public static <K, V> SortedSetMultimap<K, V> createSortedSetMultiValueMap(Comparator<V> comparator) {
		return (SortedSetMultimap<K, V>) MultimapBuilder.hashKeys().treeSetValues(comparator);
	}
485304
private SortedMap<Object, ResetableIterator> regroup(Object key,
                                                       Iterator arg1, Reporter reporter) throws IOException {
    this.numOfValues = 0;
    SortedMap<Object, ResetableIterator> retv = new TreeMap<Object, ResetableIterator>();
    TaggedMapOutput aRecord = null;
    while (arg1.hasNext()) {
      this.numOfValues += 1;
      if (this.numOfValues % 100 == 0) {
        reporter.setStatus("key: " + key.toString() + " numOfValues: "
                           + this.numOfValues);
      }
      if (this.numOfValues > this.maxNumOfValuesPerGroup) {
        continue;
      }
      aRecord = ((TaggedMapOutput) arg1.next()).clone(job);
      Text tag = aRecord.getTag();
      ResetableIterator data = retv.get(tag);
      if (data == null) {
        data = createResetableIterator();
        retv.put(tag, data);
      }
      data.add(aRecord);
    }
    if (this.numOfValues > this.largestNumOfValues) {
      this.largestNumOfValues = numOfValues;
      LOG.info("key: " + key.toString() + " this.largestNumOfValues: "
               + this.largestNumOfValues);
    }
    return retv;
  }
1374361
public static <K> NumberMap<K, Integer> newIntegerMap() {
		return new NumberMap<K, Integer>() {
			@Override
			public void add(K key, Integer addend) {
				put(key, containsKey(key) ? (get(key) + addend) : addend);
			}
			@Override
			public void sub(K key, Integer subtrahend) {
				put(key, (containsKey(key) ? get(key) : 0) - subtrahend);
			}
		};
	}
1160831
private void CalculateMap(IntRange inRange, IntRange outRange, int[] map) {
        double k = 0, b = 0;

        if (inRange.getMax() != inRange.getMin()) {
            k = (double) (outRange.getMax() - outRange.getMin()) / (double) (inRange.getMax() - inRange.getMin());
            b = (double) (outRange.getMin()) - k * inRange.getMin();
        }

        for (int i = 0; i < 256; i++) {
            int v = (int) i;

            if (v >= inRange.getMax())
                v = outRange.getMax();
            else if (v <= inRange.getMin())
                v = outRange.getMin();
            else
                v = (int) (k * v + b);

            map[i] = v;
        }
    }
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;
    }
  }
115058
public static <K, V> void putIntoListMap(K key, V value, Map<? super K, List<V>> map) {
		List<V> list = map.get(key);
		if (list == null) {
			list = Lists.newArrayListWithCapacity(2);
			map.put(key, list);
		}
		list.add(value);
	}
538702
public static <K, V> TreeMap<K, V> newTreeMap(Map<K, V> map, Comparator<? super K> comparator) {
		final TreeMap<K, V> treeMap = new TreeMap<>(comparator);
		if (false == isEmpty(map)) {
			treeMap.putAll(map);
		}
		return treeMap;
	}
241290
public static MapBounds adjustBoundsToScaleAndMapSize(
            final GenericMapAttributeValues mapValues,
            final Rectangle paintArea,
            final MapBounds bounds,
            final double dpi) {
        MapBounds newBounds = bounds;
        if (mapValues.isUseNearestScale()) {
            newBounds = newBounds.adjustBoundsToNearestScale(
                    mapValues.getZoomLevels(),
                    mapValues.getZoomSnapTolerance(),
                    mapValues.getZoomLevelSnapStrategy(),
                    mapValues.getZoomSnapGeodetic(),
                    paintArea, dpi);
        }

        newBounds = new BBoxMapBounds(newBounds.toReferencedEnvelope(paintArea));

        if (mapValues.isUseAdjustBounds()) {
            newBounds = newBounds.adjustedEnvelope(paintArea);
        }
        return newBounds;
    }
928744
public static <K, V> Map<K, V> sortNumberMapByKeyAscending(Map<K, V> map) {
        return sortNumberMapByKeyAscending(map.entrySet());
    }
747351
private void resizeMap() {
    int[] newUnsortedKeys = Arrays.copyOf(unsortedKeys, unsortedKeys.length * 2);
    int[] newUnsortedValues = Arrays.copyOf(unsortedValues, unsortedValues.length * 2);

    unsortedKeys = newUnsortedKeys;
    unsortedValues = newUnsortedValues;
  }
1229278
public MapConfiguration createLocalMap(String crs, CrsType type, Bbox bounds, int minTileSize, int nrOfZoomLevels) {
		MapConfiguration mapConfiguration = createTmsMap(crs, type, bounds, minTileSize, nrOfZoomLevels);
		mapConfiguration.setHintValue(PROFILE, Profile.LOCAL);
		return mapConfiguration;
	}
874695
public void extendBound(double[] lowerBound, double[] upperBound) {
        base.extendBound(lowerBound, upperBound);
        baseGrid.setBase(base);
        repaint();
    }
46971
private static <K, V> ImmutableSortedMap<K, V> of(Comparator<? super K> comparator, K k1, V v1) {
    return new RegularImmutableSortedMap<K, V>(
        new RegularImmutableSortedSet<K>(ImmutableList.of(k1), checkNotNull(comparator)),
        ImmutableList.of(v1));
  }
888385
private void subsection(TileBasedMap map, Space space, ArrayList spaces) {
		if (!clear(map, space)) {
			float width2 = space.getWidth()/2;
			float height2 = space.getHeight()/2;
			
			if ((width2 < smallestSpace) && (height2 < smallestSpace)) {
				return;
			}
			
			subsection(map, new Space(space.getX(), space.getY(), width2, height2), spaces);
			subsection(map, new Space(space.getX(), space.getY()+height2, width2, height2), spaces);
			subsection(map, new Space(space.getX()+width2, space.getY(), width2, height2), spaces);
			subsection(map, new Space(space.getX()+width2, space.getY()+height2, width2, height2), spaces);
		} else {
			spaces.add(space);
		}
	}
472726
Map<Integer, Pair<Integer, Integer>> constructRingMap(Map<Integer, List<Integer>> treeMap,
                                                                  Map<Integer, Integer> parentMap) {
        assert parentMap.get(0) == -1;

        List<Integer> sharedRing = constructShareRing(treeMap, parentMap, 0);
        assert sharedRing.size() == treeMap.size();

        Map<Integer, Pair<Integer, Integer>> ringMap = new LinkedHashMap<>(numWorkers);
        for(int r = 0; r < numWorkers; r++) {
            int rPrev = (r + numWorkers - 1) % numWorkers;
            int rNext = (r + 1) % numWorkers;
            ringMap.put(sharedRing.get(r), new Pair<>(sharedRing.get(rPrev), sharedRing.get(rNext)));
        }
        return ringMap;
    }
1057499
public final ReadOnlyObjectProperty<LatLongBounds> boundsProperty() {
        if (bounds == null) {
            bounds = new ReadOnlyObjectWrapper<>(getBounds());
            addStateEventHandler(MapStateEventType.idle, () -> {
                bounds.set(getBounds());
            });
        }
        return bounds.getReadOnlyProperty();
    }