Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: pkg/barback/lib/src/asset/asset_set.dart

Issue 267393009: Transition barback's infrastructure to an aggregate-based model. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/barback/lib/src/asset/asset_node_set.dart ('k') | pkg/barback/lib/src/errors.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
11 11
12 /// A set of [Asset]s with distinct IDs. 12 /// A set of [Asset]s with distinct IDs.
13 /// 13 ///
14 /// This uses the [AssetId] of each asset to determine uniqueness, so no two 14 /// This uses the [AssetId] of each asset to determine uniqueness, so no two
15 /// assets with the same ID can be in the set. 15 /// assets with the same ID can be in the set.
16 class AssetSet extends IterableBase<Asset> { 16 class AssetSet extends IterableBase<Asset> {
17 final _assets = new Map<AssetId, Asset>(); 17 final _assets = new Map<AssetId, Asset>();
18 18
19 /// The ids of the assets in the set.
20 Iterable<AssetId> get ids => _assets.keys;
21
19 AssetSet(); 22 AssetSet();
20 23
21 /// Creates a new AssetSet from the contents of [other]. 24 /// Creates a new AssetSet from the contents of [other].
22 /// 25 ///
23 /// If multiple assets in [other] have the same id, the last one takes 26 /// If multiple assets in [other] have the same id, the last one takes
24 /// precedence. 27 /// precedence.
25 AssetSet.from(Iterable<Asset> other) { 28 AssetSet.from(Iterable<Asset> other) {
26 for (var asset in other) { 29 for (var asset in other) {
27 _assets[asset.id] = asset; 30 _assets[asset.id] = asset;
28 } 31 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 /// If the set contains an [Asset] with [id], removes and returns it. 67 /// If the set contains an [Asset] with [id], removes and returns it.
65 Asset removeId(AssetId id) => _assets.remove(id); 68 Asset removeId(AssetId id) => _assets.remove(id);
66 69
67 /// Removes all assets from the set. 70 /// Removes all assets from the set.
68 void clear() { 71 void clear() {
69 _assets.clear(); 72 _assets.clear();
70 } 73 }
71 74
72 String toString() => _assets.toString(); 75 String toString() => _assets.toString();
73 } 76 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/asset/asset_node_set.dart ('k') | pkg/barback/lib/src/errors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698