| 3040 | } |
| 3041 | |
| 3042 | void Value::resize(ArrayIndex newSize) { |
| 3043 | JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue, |
| 3044 | "in Json::Value::resize(): requires arrayValue"); |
| 3045 | if (type_ == nullValue) |
| 3046 | *this = Value(arrayValue); |
| 3047 | ArrayIndex oldSize = size(); |
| 3048 | if (newSize == 0) |
| 3049 | clear(); |
| 3050 | else if (newSize > oldSize) |
| 3051 | (*this)[newSize - 1]; |
| 3052 | else { |
| 3053 | for (ArrayIndex index = newSize; index < oldSize; ++index) { |
| 3054 | value_.map_->erase(index); |
| 3055 | } |
| 3056 | assert(size() == newSize); |
| 3057 | } |
| 3058 | } |
| 3059 | |
| 3060 | Value& Value::operator[](ArrayIndex index) { |
| 3061 | JSON_ASSERT_MESSAGE( |