entry API
HashMap's way to insert-or-update a key in one lookup.
map.entry(key) returns an Entry for an occupied or vacant slot; or_insert, or_insert_with, and and_modify update or fill it with a single hash lookup.
Loading interactive…
Examples
*tally.entry(drink).or_insert(0) += 1;counts each drink with one lookup, starting a new key at 0.