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

Unified Diff: pkg/barback/lib/src/asset_set.dart

Issue 21226004: Refactor the barback tests somewhat. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/barback/lib/src/cancelable_future.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/asset_set.dart
diff --git a/pkg/barback/lib/src/asset_set.dart b/pkg/barback/lib/src/asset_set.dart
index f58e188cb2be5e5ff2f75b2a28dbf72e40e622c6..b432425608b2b7b3d79fc7aabe1a47a54dfcde45 100644
--- a/pkg/barback/lib/src/asset_set.dart
+++ b/pkg/barback/lib/src/asset_set.dart
@@ -18,6 +18,18 @@ import 'asset_id.dart';
class AssetSet extends IterableBase<Asset> {
final _assets = new Map<AssetId, Asset>();
+ AssetSet();
+
+ /// Creates a new AssetSet from the contents of [other].
+ ///
+ /// If multiple assets in [other] have the same id, the last one takes
+ /// precedence.
+ AssetSet.from(Iterable<Asset> other) {
+ for (var asset in other) {
+ _assets[asset.id] = asset;
+ }
+ }
+
Iterator<Asset> get iterator => _assets.values.iterator;
int get length => _assets.length;
@@ -51,6 +63,9 @@ class AssetSet extends IterableBase<Asset> {
return _assets.containsKey(id);
}
+ /// If the set contains an [Asset] with [id], removes and returns it.
+ Asset removeId(AssetId id) => _assets.remove(id);
+
/// Removes all assets from the set.
void clear() {
_assets.clear();
« no previous file with comments | « no previous file | pkg/barback/lib/src/cancelable_future.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698