std::map

Data / Composite

Description

A sorted key-value container from the C++ Standard Library. Available without any #include. In C++ Mode, std::map replaces IntDict, FloatDict, StringDict, and Java's HashMap. Keys are kept in sorted order.

Syntax

std::map ages std::map scores ages["alice"] = 30 int a = ages["alice"]

Parameters

None

Returns

std::map

Methods

operator[](K k)Access or insert value for key
at(K k)Access value with bounds check, throws if missing
count(K k)Returns 1 if key exists, 0 otherwise
find(K k)Returns iterator to element, or end() if not found
insert({k, v})Insert a key-value pair
erase(K k)Remove a key-value pair
size()Number of entries
empty()True if map has no entries
clear()Remove all entries
begin() / end()Iterators — each element is a std::pair

Related

Under the Hood

Implementation in Processing.h / Processing.cpp:

Loading...