OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library barback.asset.asset_set; | 5 library barback.asset.asset_set; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'asset.dart'; | 9 import 'asset.dart'; |
10 import 'asset_id.dart'; | 10 import 'asset_id.dart'; |
(...skipping 19 matching lines...) Expand all Loading... |
30 _assets[asset.id] = asset; | 30 _assets[asset.id] = asset; |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 Iterator<Asset> get iterator => _assets.values.iterator; | 34 Iterator<Asset> get iterator => _assets.values.iterator; |
35 | 35 |
36 int get length => _assets.length; | 36 int get length => _assets.length; |
37 | 37 |
38 /// Gets the [Asset] in the set with [id], or returns `null` if no asset with | 38 /// Gets the [Asset] in the set with [id], or returns `null` if no asset with |
39 /// that ID is present. | 39 /// that ID is present. |
40 Asset operator[](AssetId id) => _assets[id]; | 40 Asset operator [](AssetId id) => _assets[id]; |
41 | 41 |
42 /// Adds [asset] to the set. | 42 /// Adds [asset] to the set. |
43 /// | 43 /// |
44 /// If there is already an asset with that ID in the set, it is replaced by | 44 /// If there is already an asset with that ID in the set, it is replaced by |
45 /// the new one. Returns [asset]. | 45 /// the new one. Returns [asset]. |
46 Asset add(Asset asset) { | 46 Asset add(Asset asset) { |
47 _assets[asset.id] = asset; | 47 _assets[asset.id] = asset; |
48 return asset; | 48 return asset; |
49 } | 49 } |
50 | 50 |
(...skipping 13 matching lines...) Expand all Loading... |
64 /// If the set contains an [Asset] with [id], removes and returns it. | 64 /// If the set contains an [Asset] with [id], removes and returns it. |
65 Asset removeId(AssetId id) => _assets.remove(id); | 65 Asset removeId(AssetId id) => _assets.remove(id); |
66 | 66 |
67 /// Removes all assets from the set. | 67 /// Removes all assets from the set. |
68 void clear() { | 68 void clear() { |
69 _assets.clear(); | 69 _assets.clear(); |
70 } | 70 } |
71 | 71 |
72 String toString() => _assets.toString(); | 72 String toString() => _assets.toString(); |
73 } | 73 } |
OLD | NEW |