feat(facade/collection): add StringMap support

This commit is contained in:
Tobias Bosch 2014-10-28 14:46:38 -07:00
parent d4c099de8c
commit d0c870fb32
2 changed files with 24 additions and 0 deletions

View File

@ -14,6 +14,17 @@ class MapWrapper {
static int size(m) {return m.length;}
}
// TODO: how to export StringMap=Map as a type?
class StringMapWrapper {
static HashMap create() => new HashMap();
static get(map, key) {
return map[key];
}
static set(map, key, value) {
map[key] = value;
}
}
class ListWrapper {
static List clone(List l) => new List.from(l);
static List create() => new List();

View File

@ -13,6 +13,19 @@ export class MapWrapper {
static size(m) {return m.size;}
}
// TODO: cannot export StringMap as a type as Dart does not support
// renaming types...
export class StringMapWrapper {
// Note: We are not using Object.create(null) here due to
// performance!
static create():Object { return { }; }
static get(map, key) {
return map.hasOwnProperty(key) ? map[key] : undefined;
}
static set(map, key, value) {
map[key] = value;
}
}
export class ListWrapper {
static create():List { return new List(); }