Tangible Software Solutions

The Most Trusted Name in Source Code Conversion

  • Trusted for over 12 Years
  • Saves Valuable Time
  • Accurate and Reliable
  • Responsive Support

C++ Equivalent to Java HashMap

The nearly exact C++ equivalent to Java's HashMap collection is the std::unordered_map collection.

Original Java:

void HashMaps()
    java.util.HashMap<String, Integer> myDictionary = new java.util.HashMap<String, Integer>();
    String s = "test";
    myDictionary.put(s, 1);
    int i = myDictionary.get(s);
    i = myDictionary.size();
    boolean b = myDictionary.isEmpty();

Equivalent C++:

#include <string>
#include <unordered_map>

virtual void HashMaps()
    std::unordered_map<std::wstring, int> myDictionary;
    std::wstring s = L"test";
    myDictionary.emplace(s, 1);
    int i = myDictionary[s];
    i = myDictionary.size();
    bool b = myDictionary.empty();

If you need to convert from Java to C++ and you are depending on the results being reliable and accurate, then you will want to have Java to C++ Converter, the best Java to C++ converter, at your fingertips.

Copyright © 1997 - 2017 Tangible Software Solutions Inc.