Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #170 Get map size

Set n to the number of elements stored in mymap.

This is not always equal to the map capacity.

uses fgl;
n := MyMap.Count;
(def n (count mymap))
auto n = mymap.size();
n = mymap.Count;
const n = mymap.length;
var n = mymap.length;
n := len(mymap)
def n = mymap.size()
import qualified Data.Map as Map
getMapSize :: Map.Map k v -> Int
getMapSize m = Map.size m
const n = mymap.size
int n = mymap.size();
local n=0
for _ in pairs(mymap) do n=n+1 end
$n = count($mymap);
my $n = keys %mymap;
n = len(mymap)
n = mymap.size
let n = mymap.len();
val n = mymap.size
n := mymap size.

New implementation...
< >
programming-idioms.org