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

Side by Side Diff: samples/swarm/DataSource.dart

Issue 11414069: Make mappedBy lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload due to error. Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** The top-level collection of all sections for a user. */ 5 /** The top-level collection of all sections for a user. */
6 // TODO(jimhug): This is known as UserData in the server model. 6 // TODO(jimhug): This is known as UserData in the server model.
7 class Sections extends Collection<Section> { 7 class Sections extends Collection<Section> {
8 final List<Section> _sections; 8 final List<Section> _sections;
9 9
10 Sections(this._sections); 10 Sections(this._sections);
11 11
12 operator [](int i) => _sections[i]; 12 operator [](int i) => _sections[i];
13 13
14 int get length => _sections.length; 14 int get length => _sections.length;
15 15
16 List<String> get sectionTitles => 16 List<String> get sectionTitles =>
17 CollectionUtils.mappedBy(_sections, (s) => s.title); 17 _sections.mappedBy((s) => s.title).toList();
18 18
19 void refresh() { 19 void refresh() {
20 // TODO(jimhug): http://b/issue?id=5351067 20 // TODO(jimhug): http://b/issue?id=5351067
21 } 21 }
22 22
23 /** 23 /**
24 * Find the Section object that has a given title. 24 * Find the Section object that has a given title.
25 * This is used to integrate well with [ConveyorView]. 25 * This is used to integrate well with [ConveyorView].
26 */ 26 */
27 Section findSection(String name) { 27 Section findSection(String name) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (name == _sections[i].title) { 80 if (name == _sections[i].title) {
81 return i; 81 return i;
82 } 82 }
83 } 83 }
84 return -1; 84 return -1;
85 } 85 }
86 86
87 List<Section> get sections => _sections; 87 List<Section> get sections => _sections;
88 88
89 // Collection<Section> methods: 89 // Collection<Section> methods:
90 List mappedBy(f(Section element)) {
91 return Collections.mappedBy(this, new List(), f);
92 }
93
94 List<Section> where(bool f(Section element)) { 90 List<Section> where(bool f(Section element)) {
95 return Collections.where(this, new List<Section>(), f); 91 return Collections.where(this, new List<Section>(), f);
96 } 92 }
97 bool every(bool f(Section element)) => Collections.every(this, f); 93 bool every(bool f(Section element)) => Collections.every(this, f);
98 bool some(bool f(Section element)) => Collections.some(this, f); 94 bool some(bool f(Section element)) => Collections.some(this, f);
99 void forEach(void f(Section element)) { Collections.forEach(this, f); } 95 void forEach(void f(Section element)) { Collections.forEach(this, f); }
100 96
101 // TODO(jmesserly): this should be a property 97 // TODO(jmesserly): this should be a property
102 bool get isEmpty => length == 0; 98 bool get isEmpty => length == 0;
103 } 99 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 final hasThumbnail = decoder.readBool(); 235 final hasThumbnail = decoder.readBool();
240 final author = decoder.readString(); 236 final author = decoder.readString();
241 final dateInSeconds = decoder.readInt(); 237 final dateInSeconds = decoder.readInt();
242 final snippet = decoder.readString(); 238 final snippet = decoder.readString();
243 final date = 239 final date =
244 new Date.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true); 240 new Date.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true);
245 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, 241 return new Article(source, id, date, title, author, srcUrl, hasThumbnail,
246 snippet); 242 snippet);
247 } 243 }
248 } 244 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698