| OLD | NEW |
| (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 } | |
| OLD | NEW |