MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / avl_map

Class avl_map

code/data-structures/avl_map.cpp:2–13  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "avl_tree.cpp"
2template <class K, class V> struct avl_map {
3 struct node {
4 K key; V value;
5 node(K k, V v) : key(k), value(v) { }
6 bool operator <(const node &other) const {
7 return key < other.key; } };
8 avl_tree<node> tree;
9 V& operator [](K key) {
10 typename avl_tree<node>::node *n =
11 tree.find(node(key, V(0)));
12 if (!n) n = tree.insert(node(key, V(0)));
13 return n->item.value; } };
14// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 3

nodeClass · 0.70
findMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected