From 1f020bfb92275cbc5130526d2bc12f4da15b13f2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 1 Jul 2004 11:47:52 +0000 Subject: [PATCH] implementation of the range insert for wxStringArray (patch 975003) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28133 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/string.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/common/string.cpp b/src/common/string.cpp index 2401cc6388..ffddc7611e 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -2221,6 +2221,30 @@ void wxArrayString::Insert(const wxString& str, size_t nIndex, size_t nInsert) m_nCount += nInsert; } +// range insert (STL 23.2.4.3) +void +wxArrayString::insert(iterator it, const_iterator first, const_iterator last) +{ + const int idx = it - begin(); + + // grow it once + Grow(last - first); + + // reset "it" since it can change inside Grow() + it = begin() + idx; + + while ( first != last ) + { + it = insert(it, *first); + + // insert returns an iterator to the last element inserted but we need + // insert the next after this one, that is before the next one + ++it; + + ++first; + } +} + // expand the array void wxArrayString::SetCount(size_t count) { -- 2.45.2