Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
#include <map>
std::map<const char*, int> x;
x["one"] = 1;
x["two"] = 2;
#include <unordered_map>
std::unordered_map<std::string, double> mymap = {
    {"mom", 5.4},
    {"dad", 6.1},
    {"bro", 5.9}
};
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Hash;

use Ada.Containers;
declare
   package Maps is new Indefinite_Hashed_Maps (Key_Type => String,
                                               Element_Type => Integer,
                                               Hash => Ada.Strings.Hash,
                                               Equivalent_Keys => "=");
      
   use Maps;
      
   X : Map := Empty_Map;
begin
   X.Insert ("One", 1);
   X.Insert ("Two", 2);
   X.Insert ("Three", 3);
end;

New implementation...