操作符assing方法

void operator []=(
  1. K key,
  2. V value
)
override

将给定的valuekey关联。

如果key已经存在于map中,它的关联值将被更改。否则,将key/value对添加到map中。

实现

void operator []=(K key, V value) {
  // Splay on the key to move the last node on the search path for
  // the key to the root of the tree.
  int comp = _splay(key);
  if (comp == 0) {
    _root = _root!._replaceValue(value);
    // To represent structure change, in case someone caches the old node.
    _splayCount += 1;
    return;
  }
  _addNewRoot(_SplayTreeMapNode(key, value), comp);
}