Commit fc6d7a59 authored by Philipp A. Hartmann's avatar Philipp A. Hartmann

GenericValue: rename Erase(ConstMemberIterator) to EraseMember

parent 82b32a93
...@@ -850,7 +850,7 @@ public: ...@@ -850,7 +850,7 @@ public:
/*! \param m member iterator (obtained by FindMember() or MemberBegin()). /*! \param m member iterator (obtained by FindMember() or MemberBegin()).
\return the new iterator after removal. \return the new iterator after removal.
\note Removing member is implemented by moving the last member. So the ordering of members is changed. \note Removing member is implemented by moving the last member. So the ordering of members is changed.
\note Use \ref Erase(ConstMemberIterator) instead, if you need to rely on a stable member ordering. \note Use \ref EraseMember(ConstMemberIterator) instead, if you need to rely on a stable member ordering.
*/ */
MemberIterator RemoveMember(MemberIterator m) { MemberIterator RemoveMember(MemberIterator m) {
RAPIDJSON_ASSERT(IsObject()); RAPIDJSON_ASSERT(IsObject());
...@@ -878,8 +878,8 @@ public: ...@@ -878,8 +878,8 @@ public:
If the iterator \c pos refers to the last element, the \ref MemberEnd() iterator is returned. If the iterator \c pos refers to the last element, the \ref MemberEnd() iterator is returned.
\note Other than \ref RemoveMember(MemberIterator), this function preserves the ordering of the members. \note Other than \ref RemoveMember(MemberIterator), this function preserves the ordering of the members.
*/ */
MemberIterator Erase(ConstMemberIterator pos) { MemberIterator EraseMember(ConstMemberIterator pos) {
return Erase(pos, pos +1); return EraseMember(pos, pos +1);
} }
//! Remove members in the range [first, last) from an object. //! Remove members in the range [first, last) from an object.
...@@ -889,7 +889,7 @@ public: ...@@ -889,7 +889,7 @@ public:
\return Iterator following the last removed element. \return Iterator following the last removed element.
\note Other than \ref RemoveMember(MemberIterator), this function preserves the ordering of the members. \note Other than \ref RemoveMember(MemberIterator), this function preserves the ordering of the members.
*/ */
MemberIterator Erase(ConstMemberIterator first, ConstMemberIterator last) { MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) {
RAPIDJSON_ASSERT(IsObject()); RAPIDJSON_ASSERT(IsObject());
RAPIDJSON_ASSERT(data_.o.size > 0); RAPIDJSON_ASSERT(data_.o.size > 0);
RAPIDJSON_ASSERT(data_.o.members != 0); RAPIDJSON_ASSERT(data_.o.members != 0);
......
...@@ -789,7 +789,7 @@ TEST(Value, Object) { ...@@ -789,7 +789,7 @@ TEST(Value, Object) {
EXPECT_TRUE(x.MemberBegin() == x.MemberEnd()); EXPECT_TRUE(x.MemberBegin() == x.MemberEnd());
// Erase(ConstMemberIterator) // EraseMember(ConstMemberIterator)
// Use array members to ensure removed elements' destructor is called. // Use array members to ensure removed elements' destructor is called.
// { "a": [0], "b": [1],[2],...] // { "a": [0], "b": [1],[2],...]
...@@ -798,7 +798,7 @@ TEST(Value, Object) { ...@@ -798,7 +798,7 @@ TEST(Value, Object) {
x.AddMember(keys[i], Value(kArrayType).PushBack(i, allocator), allocator); x.AddMember(keys[i], Value(kArrayType).PushBack(i, allocator), allocator);
// Erase the first // Erase the first
itr = x.Erase(x.MemberBegin()); itr = x.EraseMember(x.MemberBegin());
EXPECT_FALSE(x.HasMember(keys[0])); EXPECT_FALSE(x.HasMember(keys[0]));
EXPECT_EQ(x.MemberBegin(), itr); EXPECT_EQ(x.MemberBegin(), itr);
EXPECT_EQ(9u, x.MemberEnd() - x.MemberBegin()); EXPECT_EQ(9u, x.MemberEnd() - x.MemberBegin());
...@@ -809,7 +809,7 @@ TEST(Value, Object) { ...@@ -809,7 +809,7 @@ TEST(Value, Object) {
} }
// Erase the last // Erase the last
itr = x.Erase(x.MemberEnd() - 1); itr = x.EraseMember(x.MemberEnd() - 1);
EXPECT_FALSE(x.HasMember(keys[9])); EXPECT_FALSE(x.HasMember(keys[9]));
EXPECT_EQ(x.MemberEnd(), itr); EXPECT_EQ(x.MemberEnd(), itr);
EXPECT_EQ(8u, x.MemberEnd() - x.MemberBegin()); EXPECT_EQ(8u, x.MemberEnd() - x.MemberBegin());
...@@ -820,7 +820,7 @@ TEST(Value, Object) { ...@@ -820,7 +820,7 @@ TEST(Value, Object) {
} }
// Erase the middle // Erase the middle
itr = x.Erase(x.MemberBegin() + 4); itr = x.EraseMember(x.MemberBegin() + 4);
EXPECT_FALSE(x.HasMember(keys[5])); EXPECT_FALSE(x.HasMember(keys[5]));
EXPECT_EQ(x.MemberBegin() + 4, itr); EXPECT_EQ(x.MemberBegin() + 4, itr);
EXPECT_EQ(7u, x.MemberEnd() - x.MemberBegin()); EXPECT_EQ(7u, x.MemberEnd() - x.MemberBegin());
...@@ -831,7 +831,7 @@ TEST(Value, Object) { ...@@ -831,7 +831,7 @@ TEST(Value, Object) {
EXPECT_EQ(i, itr->value[0u].GetInt()); EXPECT_EQ(i, itr->value[0u].GetInt());
} }
// Erase(ConstMemberIterator, ConstMemberIterator) // EraseMember(ConstMemberIterator, ConstMemberIterator)
// Exhaustive test with all 0 <= first < n, first <= last <= n cases // Exhaustive test with all 0 <= first < n, first <= last <= n cases
const unsigned n = 10; const unsigned n = 10;
for (unsigned first = 0; first < n; first++) { for (unsigned first = 0; first < n; first++) {
...@@ -840,7 +840,7 @@ TEST(Value, Object) { ...@@ -840,7 +840,7 @@ TEST(Value, Object) {
for (unsigned i = 0; i < n; i++) for (unsigned i = 0; i < n; i++)
x.AddMember(keys[i], Value(kArrayType).PushBack(i, allocator), allocator); x.AddMember(keys[i], Value(kArrayType).PushBack(i, allocator), allocator);
itr = x.Erase(x.MemberBegin() + first, x.MemberBegin() + last); itr = x.EraseMember(x.MemberBegin() + first, x.MemberBegin() + last);
if (last == n) if (last == n)
EXPECT_EQ(x.MemberEnd(), itr); EXPECT_EQ(x.MemberEnd(), itr);
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment