delete method

void delete(
  1. String key
)

Implementation

void delete(String key) {
  if (_cache.containsKey(key)) {
    _cache.remove(key);
    _deleteNode(_root, key);
    if (_root.keys.isEmpty && !_root.leaf) {
      _root = _root.children.first;
    }
  } else {
    throw Exception("Key not found");
  }
}