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

Side by Side Diff: samples/webcomponents/list_map.dart

Issue 10964030: A variety of cleanups to bring our samples up-to-date. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * ListMap class so that we have a dictionary usable with non-hashable keys.
7 * Note: this class does NOT yet have full Map functionality
8 */
9 class ListMap<K, V> {
10
11 List<_Pair<K, V>> _list;
12
13 ListMap()
14 : _list = new List<_Pair<K, V>>() { }
15
16 void operator []=(K key, V value) {
17 _list.add(new _Pair<K,V>(key, value));
18 }
19
20 V operator [](K key) {
21 for (var pair in _list) {
22 if (pair._key == key)
23 return pair._value;
24 }
25 return null;
26 }
27 }
28
29 class _Pair<K, V> {
30 K _key;
31 V _value;
32
33 _Pair(this._key, this._value);
34 }
OLDNEW
« no previous file with comments | « samples/webcomponents/contactifier/contactifier.html ('k') | samples/webcomponents/shadow_polyfill.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698