@@ -142,17 +142,17 @@ class GrowableArrayView : public GrowableArrayBase {
142
142
}
143
143
144
144
E& at (int i) {
145
- assert (0 <= i && i < _len, " illegal index" );
145
+ assert (0 <= i && i < _len, " illegal index %d for length %d " , i, _len );
146
146
return _data[i];
147
147
}
148
148
149
149
E const & at (int i) const {
150
- assert (0 <= i && i < _len, " illegal index" );
150
+ assert (0 <= i && i < _len, " illegal index %d for length %d " , i, _len );
151
151
return _data[i];
152
152
}
153
153
154
154
E* adr_at (int i) const {
155
- assert (0 <= i && i < _len, " illegal index" );
155
+ assert (0 <= i && i < _len, " illegal index %d for length %d " , i, _len );
156
156
return &_data[i];
157
157
}
158
158
@@ -184,7 +184,7 @@ class GrowableArrayView : public GrowableArrayBase {
184
184
}
185
185
186
186
void at_put (int i, const E& elem) {
187
- assert (0 <= i && i < _len, " illegal index" );
187
+ assert (0 <= i && i < _len, " illegal index %d for length %d " , i, _len );
188
188
_data[i] = elem;
189
189
}
190
190
@@ -245,7 +245,7 @@ class GrowableArrayView : public GrowableArrayBase {
245
245
}
246
246
247
247
void remove_at (int index) {
248
- assert (0 <= index && index < _len, " illegal index" );
248
+ assert (0 <= index && index < _len, " illegal index %d for length %d " , index , _len );
249
249
for (int j = index + 1 ; j < _len; j++) {
250
250
_data[j-1 ] = _data[j];
251
251
}
@@ -259,8 +259,8 @@ class GrowableArrayView : public GrowableArrayBase {
259
259
260
260
// Remove all elements in the range [start - end). The order is preserved.
261
261
void remove_range (int start, int end) {
262
- assert (0 <= start, " illegal index" );
263
- assert (start < end && end <= _len, " erase called with invalid range" );
262
+ assert (0 <= start, " illegal start index %d " , start );
263
+ assert (start < end && end <= _len, " erase called with invalid range (%d, %d) for length %d " , start, end, _len );
264
264
265
265
for (int i = start, j = end; j < length (); i++, j++) {
266
266
at_put (i, at (j));
@@ -270,7 +270,7 @@ class GrowableArrayView : public GrowableArrayBase {
270
270
271
271
// The order is changed.
272
272
void delete_at (int index) {
273
- assert (0 <= index && index < _len, " illegal index" );
273
+ assert (0 <= index && index < _len, " illegal index %d for length %d " , index , _len );
274
274
if (index < --_len) {
275
275
// Replace removed element with last one.
276
276
_data[index ] = _data[_len];
@@ -403,7 +403,7 @@ class GrowableArrayWithAllocator : public GrowableArrayView<E> {
403
403
void push (const E& elem) { append (elem); }
404
404
405
405
E at_grow (int i, const E& fill = E()) {
406
- assert (0 <= i, " negative index" );
406
+ assert (0 <= i, " negative index %d " , i );
407
407
if (i >= this ->_len ) {
408
408
if (i >= this ->_capacity ) grow (i);
409
409
for (int j = this ->_len ; j <= i; j++)
@@ -414,7 +414,7 @@ class GrowableArrayWithAllocator : public GrowableArrayView<E> {
414
414
}
415
415
416
416
void at_put_grow (int i, const E& elem, const E& fill = E()) {
417
- assert (0 <= i, " negative index" );
417
+ assert (0 <= i, " negative index %d " , i );
418
418
if (i >= this ->_len ) {
419
419
if (i >= this ->_capacity ) grow (i);
420
420
for (int j = this ->_len ; j < i; j++)
@@ -426,7 +426,7 @@ class GrowableArrayWithAllocator : public GrowableArrayView<E> {
426
426
427
427
// inserts the given element before the element at index i
428
428
void insert_before (const int idx, const E& elem) {
429
- assert (0 <= idx && idx <= this ->_len , " illegal index" );
429
+ assert (0 <= idx && idx <= this ->_len , " illegal index %d for length %d " , idx, this -> _len );
430
430
if (this ->_len == this ->_capacity ) grow (this ->_len );
431
431
for (int j = this ->_len - 1 ; j >= idx; j--) {
432
432
this ->_data [j + 1 ] = this ->_data [j];
@@ -436,7 +436,7 @@ class GrowableArrayWithAllocator : public GrowableArrayView<E> {
436
436
}
437
437
438
438
void insert_before (const int idx, const GrowableArrayView<E>* array) {
439
- assert (0 <= idx && idx <= this ->_len , " illegal index" );
439
+ assert (0 <= idx && idx <= this ->_len , " illegal index %d for length %d " , idx, this -> _len );
440
440
int array_len = array->length ();
441
441
int new_len = this ->_len + array_len;
442
442
if (new_len >= this ->_capacity ) grow (new_len);
0 commit comments