blob: a8fb925e2a0d836eac0dc6452876b5dd6f7a4b79 [file] [log] [blame]
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
/// @assertion MapBase<K, V>
/// Base class for implementing a Map.
/// This class has a basic implementation of all but five of the members of Map.
/// A basic Map class can be implemented by extending this class and implementing
/// keys, operator[], operator[]=, remove and clear. The remaining operations are
/// implemented in terms of these five.
/// @description Implementation of keys, operator[], operator[]=, remove and
/// clear
/// @author
library map_base_lib;
import "dart:collection";
class MapBaseImpl<K, V> extends MapBase<K, V> {
LinkedHashMap<K, V> _map;
MapBaseImpl(): _map = new LinkedHashMap<K, V>();
MapBaseImpl.from(Map content): _map = new LinkedHashMap<K, V>.from(content);
Iterable<K> get keys => _map.keys;
V operator [](Object key) => _map[key];
void operator []=(K key, V value) {
_map[key] = value;
void clear() {
V remove(Object key) => _map.remove(key);