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

Side by Side Diff: client/dom/common/implementation.dart

Issue 9407008: Remove unused dom/common files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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
« no previous file with comments | « no previous file | client/dom/common/public.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 class ListBase<E> extends DOMType implements List<E> {
2 ListBase();
3
4 void forEach(void f(E element)) => Collections.forEach(this, f);
5 Collection map(f(E element)) => Collections.map(this, [], f);
6 Collection<E> filter(bool f(E element)) => Collections.filter(this, [], f);
7 bool every(bool f(E element)) => Collections.every(this, f);
8 bool some(bool f(E element)) => Collections.some(this, f);
9 bool isEmpty() => Collections.isEmpty(this);
10
11 void sort(int compare(E a, E b)) {
12 throw 'Unsupported yet';
13 }
14
15 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) {
16 Arrays.copy(src, srcStart, this, dstStart, count);
17 }
18
19 int indexOf(E element, int startIndex) {
20 // FIXME: switch to dart:coreimpl when de'Array'ed.
21 if (startIndex >= length) {
22 return -1;
23 }
24 if (startIndex < 0) {
25 startIndex = 0;
26 }
27 for (int i = startIndex; i < length; i++) {
28 if (this[i] == element) {
29 return i;
30 }
31 }
32 return -1;
33 }
34
35 int lastIndexOf(E element, int startIndex) {
36 // FIXME: switch to dart:coreimpl when de'Array'ed.
37 if (startIndex < 0) {
38 return -1;
39 }
40 if (startIndex >= length) {
41 startIndex = length - 1;
42 }
43 for (int i = startIndex; i >= 0; i--) {
44 if (this[i] == element) {
45 return i;
46 }
47 }
48 return -1;
49 }
50
51 E last() => this[length - 1];
52
53 // FIXME: implement those.
54 void setRange(int start, int length, List<E> from, [int startFrom]) {
55 throw const NotImplementedException();
56 }
57 void removeRange(int start, int length) {
58 throw const NotImplementedException();
59 }
60 void insertRange(int start, int length, [E initialValue]) {
61 throw const NotImplementedException();
62 }
63 List<E> getRange(int start, int length) {
64 throw const NotImplementedException();
65 }
66
67 Iterator<E> iterator() {
68 // Note: NodeLists are not fixed size. And most probably length shouldn't
69 // be cached in both iterator _and_ forEach method. For now caching it
70 // for consistency.
71 return new _FixedSizeListIterator<E>(this);
72 }
73 }
74
75 // FIXME: switch to one from dart:coreimpl when DartVM is de'Array'ed.
76 // Iterator for lists with fixed size.
77 class _FixedSizeListIterator<E> implements Iterator<E> {
78 _FixedSizeListIterator(List list)
79 : _list = list, _length = list.length, _pos = 0 {
80 }
81
82 bool hasNext() => _length > _pos;
83
84 E next() {
85 if (!hasNext()) {
86 throw const NoMoreElementsException();
87 }
88 return _list[_pos++];
89 }
90
91 final List<E> _list;
92 final int _length; // Cache array length for faster access.
93 int _pos;
94 }
95
96 class MapBase<K, V> extends DOMType implements Map<K, V> {
97 MapBase();
98
99 bool containsValue(V value) => Maps.containsValue(this, value);
100 bool containsKey(K key) => Maps.containsKey(this, key);
101 V putIfAbsent(K key, V ifAbsent()) => Maps.putIfAbsent(this, key, ifAbsent);
102 clear() => Maps.clear(this);
103 forEach(void f(K key, V value)) => Maps.forEach(this, f);
104 Collection<V> getValues() => Maps.getValues(this);
105 int get length() => Maps.length(this);
106 bool isEmpty() => Maps.isEmpty(this);
107
108 V operator [](K key) {
109 throw 'Must be implemented';
110 }
111
112 operator []=(K key, V value) {
113 throw 'Immutable collection';
114 }
115
116 V remove(K key) {
117 throw 'Immutable collection';
118 }
119
120 Collection<K> getKeys() {
121 throw 'Must be implemented';
122 }
123 }
OLDNEW
« no previous file with comments | « no previous file | client/dom/common/public.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698