• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 15-Day Money-Back Guarantee

Java Equivalent to C++ std::unordered_map

The nearly exact Java equivalent to the C++ std::unordered_map collection is the Java HashMap collection. (The Java equivalent to the C++ std::map collection is the TreeMap collection).

C++ Java
#include <string>
#include <unordered_map>

virtual void UnorderedMap()
    std::unordered_map<std::wstring, int> map;
    std::wstring s = L"test";
    map[s] = 1;
    int i = map[s];
    i = map.size();
    bool b = map.empty();
void UnorderedMap()
    java.util.HashMap<String, Integer> map = new java.util.HashMap<String, Integer>();
    String s = "test";
    map.put(s, 1);
    int i = map.get(s);
    i = map.size();
    boolean b = map.isEmpty();

Use C++ to Java Converter to convert from C++ to Java.     

Additional resource: Java and C++ Equivalents

Copyright © 2004 – 2021 Tangible Software Solutions, Inc.