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

Side by Side Diff: runtime/lib/growable_array.dart

Issue 10982045: Make data setter private on GrowableObjectArray. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | runtime/lib/lib_impl_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class GrowableObjectArray<T> implements List<T> { 5 class GrowableObjectArray<T> implements List<T> {
6 factory GrowableObjectArray._uninstantiable() { 6 factory GrowableObjectArray._uninstantiable() {
7 throw const UnsupportedOperationException( 7 throw const UnsupportedOperationException(
8 "GrowableObjectArray can only be allocated by the VM"); 8 "GrowableObjectArray can only be allocated by the VM");
9 } 9 }
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } else { 101 } else {
102 for (int i = new_length; i < length; i++) { 102 for (int i = new_length; i < length; i++) {
103 this[i] = null; 103 this[i] = null;
104 } 104 }
105 } 105 }
106 _setLength(new_length); 106 _setLength(new_length);
107 } 107 }
108 108
109 void _setLength(int new_length) native "GrowableObjectArray_setLength"; 109 void _setLength(int new_length) native "GrowableObjectArray_setLength";
110 110
111 void set data(ObjectArray<T> array) native "GrowableObjectArray_setData"; 111 void _setData(ObjectArray<T> array) native "GrowableObjectArray_setData";
srdjan 2012/09/26 15:33:00 Please adapt intrinsifier.h (s/set:data/_setData/)
Mads Ager (google) 2012/09/26 16:08:31 Thanks Srdjan! Done! (That was actually how I not
112 112
113 T operator [](int index) native "GrowableObjectArray_getIndexed"; 113 T operator [](int index) native "GrowableObjectArray_getIndexed";
114 114
115 void operator []=(int index, T value) native "GrowableObjectArray_setIndexed"; 115 void operator []=(int index, T value) native "GrowableObjectArray_setIndexed";
116 116
117 // The length of this growable array. It is always less than or equal to the 117 // The length of this growable array. It is always less than or equal to the
118 // length of the object array, which itself is always greater than 0, so that 118 // length of the object array, which itself is always greater than 0, so that
119 // grow() does not have to check for a zero length object array before 119 // grow() does not have to check for a zero length object array before
120 // doubling its size. 120 // doubling its size.
121 void add(T value) { 121 void add(T value) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 int lastIndexOf(T element, [int start = null]) { 156 int lastIndexOf(T element, [int start = null]) {
157 if (start === null) start = length - 1; 157 if (start === null) start = length - 1;
158 return Arrays.lastIndexOf(this, element, start); 158 return Arrays.lastIndexOf(this, element, start);
159 } 159 }
160 160
161 void _grow(int new_length) { 161 void _grow(int new_length) {
162 var new_data = new ObjectArray<T>(new_length); 162 var new_data = new ObjectArray<T>(new_length);
163 for (int i = 0; i < length; i++) { 163 for (int i = 0; i < length; i++) {
164 new_data[i] = this[i]; 164 new_data[i] = this[i];
165 } 165 }
166 data = new_data; 166 _setData(new_data);
167 } 167 }
168 168
169 /** 169 /**
170 * Collection interface. 170 * Collection interface.
171 */ 171 */
172 172
173 void forEach(f(T element)) { 173 void forEach(f(T element)) {
174 // TODO(srdjan): Use Collections.forEach(this, f); 174 // TODO(srdjan): Use Collections.forEach(this, f);
175 // Accessing the list directly improves DeltaBlue performance by 25%. 175 // Accessing the list directly improves DeltaBlue performance by 25%.
176 for (int i = 0; i < length; i++) { 176 for (int i = 0; i < length; i++) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 T next() { 234 T next() {
235 if (!hasNext()) { 235 if (!hasNext()) {
236 throw const NoMoreElementsException(); 236 throw const NoMoreElementsException();
237 } 237 }
238 return _array[_pos++]; 238 return _array[_pos++];
239 } 239 }
240 240
241 final GrowableObjectArray<T> _array; 241 final GrowableObjectArray<T> _array;
242 int _pos; 242 int _pos;
243 } 243 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/lib_impl_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698