Java Utililty Methods SortedMap Usage

List of utility methods to do SortedMap Usage

Description

The list of methods to do SortedMap Usage are organized into topic(s).

Method

TlastElement(List c)
last Element
if (isEmpty(c)) {
    return null;
return c.get(c.size() - 1);
voidpruneStartAndEndKeys(SortedMap setOfStartKeyByteArray, List listOfStartKeyByteArray)
prune Start And End Keys
for (Map.Entry<Integer, byte[]> entry : setOfStartKeyByteArray.entrySet()) {
    listOfStartKeyByteArray.add(entry.getValue());
voidputWeightToBin(SortedMap hist, double bin, double weight)
put Weight To Bin
if (null != hist) {
    if (hist.containsKey(bin)) {
        hist.put(bin, hist.get(bin) + weight);
    } else {
        hist.put(bin, weight);
voidremoveSetFromBulkLm(Set toRemoveSet, List> byteSizeByNameList, String exceptRegex)
Removes from the maps of the specified list, the keys of toRemoveSet, except if they match exceptRegex.
for (String key : toRemoveSet) {
    if ((exceptRegex == null) || (!key.matches(exceptRegex))) {
        for (SortedMap<String, Long> byteSizeByName : byteSizeByNameList) {
            byteSizeByName.remove(key);
SortedMapsortedMapOf(final Object obj, final Class keyCastTo, final Class valueCastTo)
sorted Map Of
return (SortedMap<K, V>) obj;
SortedMapsubmapWithPrefix(SortedMap map, String prefix)
Returns a living view of the given map containing all strings that starts with the given prefix (including the prefix string itself).
if (map.comparator() != null)
    throw new IllegalArgumentException("only natural (lexiographic) ordering supported");
int length = prefix.length();
if (length == 0)
    return map;
StringBuilder lhs = new StringBuilder(prefix);
char ch = lhs.charAt(length - 1);
lhs.setCharAt(length - 1, (char) (ch + 1));
...
ListunwrapList(SortedMap sortedMap, K fromKey)
unwrap List
List<V> list = new ArrayList<V>();
list.addAll(sortedMap.tailMap(fromKey).values());
list.addAll(sortedMap.headMap(fromKey).values());
return list;
ListunwrapList(SortedMap sortedMap, K fromKey)
Unwraps a sorted map and creates a list, starting with the element element mapped to the fromKey and then adding all elements after the from key until the end of the map, and then adding all elements from the beginning of the map up to (but not including) the first element.
List<V> list = new ArrayList<V>();
list.addAll(sortedMap.tailMap(fromKey).values());
list.addAll(sortedMap.headMap(fromKey).values());
return list;