Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 implements Collection<Section> { | 7 class Sections implements Collection<Section> { |
| 8 final List<Section> _sections; | 8 final List<Section> _sections; |
| 9 | 9 |
| 10 Sections(this._sections); | 10 Sections(this._sections); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 map(f(Section element)) { | |
| 91 return Collections.map(this, new List<Section>(), f); | |
|
ahe
2012/01/05 22:36:54
How do you know that f returns a Section?
gbracha
2012/01/12 00:53:57
I don't. It's a mistake. Fixed.
| |
| 92 } | |
| 93 | |
| 90 List<Section> filter(bool f(Section element)) { | 94 List<Section> filter(bool f(Section element)) { |
| 91 return Collections.filter(this, new List<Section>(), f); | 95 return Collections.filter(this, new List<Section>(), f); |
| 92 } | 96 } |
| 93 bool every(bool f(Section element)) => Collections.every(this, f); | 97 bool every(bool f(Section element)) => Collections.every(this, f); |
| 94 bool some(bool f(Section element)) => Collections.some(this, f); | 98 bool some(bool f(Section element)) => Collections.some(this, f); |
| 95 void forEach(void f(Section element)) { Collections.forEach(this, f); } | 99 void forEach(void f(Section element)) { Collections.forEach(this, f); } |
| 96 | 100 |
| 97 // TODO(jmesserly): this should be a property | 101 // TODO(jmesserly): this should be a property |
| 98 bool isEmpty() => length == 0; | 102 bool isEmpty() => length == 0; |
| 99 } | 103 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 final srcUrl = decoder.readString(); | 238 final srcUrl = decoder.readString(); |
| 235 final hasThumbnail = decoder.readBool(); | 239 final hasThumbnail = decoder.readBool(); |
| 236 final author = decoder.readString(); | 240 final author = decoder.readString(); |
| 237 final dateInSeconds = decoder.readInt(); | 241 final dateInSeconds = decoder.readInt(); |
| 238 final snippet = decoder.readString(); | 242 final snippet = decoder.readString(); |
| 239 final date = new Date.fromEpoch(dateInSeconds*1000, new TimeZone.utc()); | 243 final date = new Date.fromEpoch(dateInSeconds*1000, new TimeZone.utc()); |
| 240 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, | 244 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, |
| 241 snippet); | 245 snippet); |
| 242 } | 246 } |
| 243 } | 247 } |
| OLD | NEW |