Example #1
0
 public HashMap<String, WFunctionSymbol> getfunctions() {
   HashMap<String, WFunctionSymbol> functions = new HashMap<>();
   for (Symbol s : GLOBALS.getAllSymbols()) {
     if (s instanceof WFunctionSymbol) {
       functions.put(s.getName(), (WFunctionSymbol) s);
     }
   }
   return functions;
 }
Example #2
0
  public LinkedHashMap sortHashMapByValues(HashMap map) {
    List mapKeys = new ArrayList(map.keySet());
    List mapValues = new ArrayList(map.values());
    Collections.sort(mapValues);
    Collections.sort(mapKeys);

    LinkedHashMap sortedMap = new LinkedHashMap();

    Iterator valueIt = mapValues.iterator();
    while (valueIt.hasNext()) {
      Object val = valueIt.next();
      Iterator keyIt = mapKeys.iterator();

      while (keyIt.hasNext()) {
        Object key = keyIt.next();
        Object keyVal = map.get(key);
        if (keyVal == val) {
          sortedMap.put(key, keyVal);
        }
      }
    }
    return sortedMap;
  }
Example #3
0
 public int defineStringLiteral(String s) {
   if (strings.containsKey(s)) return strings.get(s);
   else strings.put(s, ++strIndex);
   return strIndex;
 }