Kaydet (Commit) 3b199abf authored tarafından Michael Stahl's avatar Michael Stahl

sorted_vector: rename nonconst methods to be more obvious

Change-Id: I4ba4164343f252ac451433ba3b07e2cd214e13f8
üst a24f1f69
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
std::pair<const_iterator,bool> insert( const Value& x ) std::pair<const_iterator,bool> insert( const Value& x )
{ {
iterator it = _lower_bound( x ); iterator it = lower_bound_nonconst( x );
if (it == base_t::end() || less_than(x, *it)) if (it == base_t::end() || less_than(x, *it))
{ {
it = base_t::insert( it, x ); it = base_t::insert( it, x );
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
size_type erase( const Value& x ) size_type erase( const Value& x )
{ {
iterator it = _lower_bound( x ); iterator it = lower_bound_nonconst( x );
if (it != base_t::end() && !less_than(x, *it)) if (it != base_t::end() && !less_than(x, *it))
{ {
erase( it ); erase( it );
...@@ -77,7 +77,7 @@ public: ...@@ -77,7 +77,7 @@ public:
void erase( size_t index ) void erase( size_t index )
{ {
base_t::erase( _begin() + index ); base_t::erase( begin_nonconst() + index );
} }
// ACCESSORS // ACCESSORS
...@@ -160,7 +160,8 @@ public: ...@@ -160,7 +160,8 @@ public:
// of another sorted vector // of another sorted vector
if ( empty() ) if ( empty() )
{ {
base_t::insert( _begin(), rOther._begin(), rOther._end() ); base_t::insert( begin_nonconst(),
rOther.begin_nonconst(), rOther.end_nonconst() );
} }
else else
for( const_iterator it = rOther.begin(); it != rOther.end(); ++it ) for( const_iterator it = rOther.begin(); it != rOther.end(); ++it )
...@@ -183,14 +184,14 @@ private: ...@@ -183,14 +184,14 @@ private:
return me.operator()(lhs, rhs); return me.operator()(lhs, rhs);
} }
iterator _lower_bound( const Value& x ) iterator lower_bound_nonconst( const Value& x )
{ {
const MyCompare& me = *this; const MyCompare& me = *this;
return std::lower_bound( base_t::begin(), base_t::end(), x, me ); return std::lower_bound( base_t::begin(), base_t::end(), x, me );
} }
typename base_t::iterator _begin() { return base_t::begin(); } typename base_t::iterator begin_nonconst() { return base_t::begin(); }
typename base_t::iterator _end() { return base_t::end(); } typename base_t::iterator end_nonconst() { return base_t::end(); }
}; };
......
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