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

Side by Side Diff: runtime/vm/growable_array.h

Issue 1410493002: Complete support for Windows TLS destructors (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | runtime/vm/os_thread.h » ('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 // Defines growable array classes, that differ where they are allocated: 4 // Defines growable array classes, that differ where they are allocated:
5 // - GrowableArray: allocated on stack. 5 // - GrowableArray: allocated on stack.
6 // - ZoneGrowableArray: allocated in the zone. 6 // - ZoneGrowableArray: allocated in the zone.
7 // - MallocGrowableArray: allocates using malloc/realloc; free is only called 7 // - MallocGrowableArray: allocates using malloc/realloc; free is only called
8 // at destruction. 8 // at destruction.
9 9
10 #ifndef VM_GROWABLE_ARRAY_H_ 10 #ifndef VM_GROWABLE_ARRAY_H_
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 void Swap(intptr_t i, intptr_t j) { 103 void Swap(intptr_t i, intptr_t j) {
104 ASSERT(i >= 0); 104 ASSERT(i >= 0);
105 ASSERT(j >= 0); 105 ASSERT(j >= 0);
106 ASSERT(i < length_); 106 ASSERT(i < length_);
107 ASSERT(j < length_); 107 ASSERT(j < length_);
108 T temp = data_[i]; 108 T temp = data_[i];
109 data_[i] = data_[j]; 109 data_[i] = data_[j];
110 data_[j] = temp; 110 data_[j] = temp;
111 } 111 }
112 112
113 // NOTE: Does not preserve array order.
114 void RemoveAt(intptr_t i) {
115 ASSERT(i >= 0);
116 ASSERT(i < length_);
117 intptr_t last = length_ - 1;
118 if (i < last) {
119 Swap(i, last);
120 }
121 RemoveLast();
122 }
123
113 // The content is uninitialized after calling it. 124 // The content is uninitialized after calling it.
114 void SetLength(intptr_t new_length); 125 void SetLength(intptr_t new_length);
115 126
116 // Sort the array in place. 127 // Sort the array in place.
117 inline void Sort(int compare(const T*, const T*)); 128 inline void Sort(int compare(const T*, const T*));
118 129
119 private: 130 private:
120 intptr_t length_; 131 intptr_t length_;
121 intptr_t capacity_; 132 intptr_t capacity_;
122 T* data_; 133 T* data_;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 public: 288 public:
278 explicit MallocGrowableArray(intptr_t initial_capacity) 289 explicit MallocGrowableArray(intptr_t initial_capacity)
279 : BaseGrowableArray<T, EmptyBase, Malloc>(initial_capacity, NULL) {} 290 : BaseGrowableArray<T, EmptyBase, Malloc>(initial_capacity, NULL) {}
280 MallocGrowableArray() 291 MallocGrowableArray()
281 : BaseGrowableArray<T, EmptyBase, Malloc>(NULL) {} 292 : BaseGrowableArray<T, EmptyBase, Malloc>(NULL) {}
282 }; 293 };
283 294
284 } // namespace dart 295 } // namespace dart
285 296
286 #endif // VM_GROWABLE_ARRAY_H_ 297 #endif // VM_GROWABLE_ARRAY_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/os_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698