Login
|
Signup
langref.org
-
ruby
,
java
,
perl
,
groovy
...
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Maps
Declaration
Define an empty map
ruby
map = []
map = []
java
Map map = new HashMap();
public class Solution10 {
public static void main(String[] args) {
Map map = new HashMap();
}
}
perl
%map = {}
%map = {}
groovy
def map = [:]
def map = [:]
groovy
Map map = new HashMap();
Map map = new HashMap();
scala
val map = mutable.Map.empty
import scala.collection.mutable;
object Solution477 extends Application {
val map = mutable.Map.empty
println(map.size)
}
scala
val map = mutable.HashMap.empty[String, Int]
import scala.collection.mutable;
object SolutionXX extends Application {
val map = mutable.HashMap.empty[String, Int]
println(map.size)
}
python
map = {}
map = {}
cpp
C++/CLI .NET 2.0
Hashtable^ hash = gcnew Hashtable;
using namespace System;
using namespace System::Collections;
int main()
{
Hashtable^ hash = gcnew Hashtable;
}
cpp
C++/CLI .NET 2.0
Generic::Dictionary<String^, String^>^ dict = gcnew Generic::Dictionary<String^, String^>();
using namespace System;
using namespace System::Collections;
int main()
{
Generic::Dictionary<String^, String^>^ dict = gcnew Generic::Dictionary<String^, String^>();
}
cpp
std::map<int, std::string> m;
int main()
{
std::map<int, std::string> m;
}
fsharp
let map = Map.empty
#light
open System
open System.Collections
let map = Map.empty
fsharp
let map = new Generic.Dictionary<string, string>()
#light
open System
open System.Collections
let map = new Generic.Dictionary<string, string>()
fsharp
let map = new Hashtable()
#light
open System
open System.Collections
let map = new Hashtable()
erlang
Map = dict:new(),
-module(emptymap).
-export([start/0]).
start() ->
Map = dict:new(),
io:format("~B~n", [dict:size(Map)]).
erlang
Map = orddict:new(),
-module(emptymap).
-export([start/0]).
start() ->
Map = orddict:new(),
io:format("~B~n", [orddict:size(Map)]).
erlang
Map = gb_trees:empty(),
-module(emptymap).
-export([start/0]).
start() ->
Map = gb_trees:empty(),
io:format("~B~n", [gb_trees:size(Map)]).
erlang
Map = ets:new(the_map_name, [set, private, {keypos, 1}]),
-module(emptymap).
-export([start/0]).
start() ->
Map = ets:new(the_map_name, [set, private, {keypos, 1}]),
io:format("~B~n", [ets:info(Map, size)]).
php
$map = array();
<?php
$map = array();
?>
php
$map = array("" => "");
<?php
$map = array("" => "");
?>
Submit a new solution for
ruby
,
java
,
perl
,
groovy
...