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

Side by Side Diff: vm/growable_array.h

Issue 11348026: - GrowableArray::RemoveLast returns the value being removed (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 1 month 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 | « vm/flow_graph_optimizer.cc ('k') | vm/parser.cc » ('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: allocate on stack. 5 // - GrowableArray: allocate on stack.
6 // - ZoneGrowableArray: allocated in the zone. 6 // - ZoneGrowableArray: allocated in the zone.
7 7
8 #ifndef VM_GROWABLE_ARRAY_H_ 8 #ifndef VM_GROWABLE_ARRAY_H_
9 #define VM_GROWABLE_ARRAY_H_ 9 #define VM_GROWABLE_ARRAY_H_
10 10
(...skipping 28 matching lines...) Expand all
39 void TruncateTo(intptr_t length) { 39 void TruncateTo(intptr_t length) {
40 ASSERT(length_ >= length); 40 ASSERT(length_ >= length);
41 length_ = length; 41 length_ = length;
42 } 42 }
43 43
44 void Add(const T& value) { 44 void Add(const T& value) {
45 Resize(length() + 1); 45 Resize(length() + 1);
46 Last() = value; 46 Last() = value;
47 } 47 }
48 48
49 void RemoveLast() { 49 T& RemoveLast() {
50 ASSERT(length_ > 0); 50 ASSERT(length_ > 0);
51 T& result = operator[](length_ - 1);
51 length_--; 52 length_--;
53 return result;
52 } 54 }
53 55
54 T& operator[](int index) const { 56 T& operator[](int index) const {
55 ASSERT(0 <= index); 57 ASSERT(0 <= index);
56 ASSERT(index < length_); 58 ASSERT(index < length_);
57 ASSERT(length_ <= capacity_); 59 ASSERT(length_ <= capacity_);
58 return data_[index]; 60 return data_[index];
59 } 61 }
60 62
61 T& Last() const { 63 T& Last() const {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 initial_capacity, 140 initial_capacity,
139 Isolate::Current()->current_zone()) {} 141 Isolate::Current()->current_zone()) {}
140 ZoneGrowableArray() : 142 ZoneGrowableArray() :
141 BaseGrowableArray<T, ZoneAllocated>( 143 BaseGrowableArray<T, ZoneAllocated>(
142 Isolate::Current()->current_zone()) {} 144 Isolate::Current()->current_zone()) {}
143 }; 145 };
144 146
145 } // namespace dart 147 } // namespace dart
146 148
147 #endif // VM_GROWABLE_ARRAY_H_ 149 #endif // VM_GROWABLE_ARRAY_H_
OLDNEW
« no previous file with comments | « vm/flow_graph_optimizer.cc ('k') | vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698