`MapBase` 和 `MapMixin` 在编码我自己的地图方面有什么区别 class?
What's the difference between `MapBase` and `MapMixin` in terms of coding my own Map class?
我想编写自己的代码 Map
class。 MapBase
和 MapMixin
有类似的文档。我应该使用哪一个来编写我自己的 Map
class?为什么?
我知道 MapBase
有更多功能,因为它实现了 MapMixin
。不过MapBase
里面的功能好像都不重要,因为它的所有功能都是static
.
...
/// 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.
...
abstract class MapBase<K, V> extends MapMixin<K, V> {
...
/// A basic `Map` class can be implemented by mixin in this class and
/// implementing `keys`, `operator[]`, `operator[]=`, `remove` and `clear`.
/// The remaining operations are implemented in terms of these five.
...
abstract class MapMixin<K, V> implements Map<K, V> {
没关系。 mixin 的优点是您可以在 class 中包含多个 mixin,而您只能从一个 class.
扩展
我想编写自己的代码 Map
class。 MapBase
和 MapMixin
有类似的文档。我应该使用哪一个来编写我自己的 Map
class?为什么?
我知道 MapBase
有更多功能,因为它实现了 MapMixin
。不过MapBase
里面的功能好像都不重要,因为它的所有功能都是static
.
...
/// 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.
...
abstract class MapBase<K, V> extends MapMixin<K, V> {
...
/// A basic `Map` class can be implemented by mixin in this class and
/// implementing `keys`, `operator[]`, `operator[]=`, `remove` and `clear`.
/// The remaining operations are implemented in terms of these five.
...
abstract class MapMixin<K, V> implements Map<K, V> {
没关系。 mixin 的优点是您可以在 class 中包含多个 mixin,而您只能从一个 class.
扩展