| 3590 | } |
| 3591 | |
| 3592 | void Value::resize(ArrayIndex newSize) |
| 3593 | { |
| 3594 | JSON_ASSERT_MESSAGE(type() == nullValue || type() == arrayValue, |
| 3595 | "in Json::Value::resize(): requires arrayValue"); |
| 3596 | if (type() == nullValue) |
| 3597 | *this = Value(arrayValue); |
| 3598 | ArrayIndex oldSize = size(); |
| 3599 | if (newSize == 0) |
| 3600 | clear(); |
| 3601 | else if (newSize > oldSize) |
| 3602 | for (ArrayIndex i = oldSize; i < newSize; ++i) |
| 3603 | (*this)[i]; |
| 3604 | else |
| 3605 | { |
| 3606 | for (ArrayIndex index = newSize; index < oldSize; ++index) |
| 3607 | { |
| 3608 | value_.map_->erase(index); |
| 3609 | } |
| 3610 | JSON_ASSERT(size() == newSize); |
| 3611 | } |
| 3612 | } |
| 3613 | |
| 3614 | Value &Value::operator[](ArrayIndex index) |
| 3615 | { |