Add ctor and assign() taking an iterator range to wxVector<>.

Do it for consistency with wxArray and std::vector<>, even if the current
implementation is suboptimal.

See #15216.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74045 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-05-22 14:13:26 +00:00
parent 41da7d974a
commit 4a8e979925
2 changed files with 45 additions and 0 deletions

View File

@@ -255,6 +255,13 @@ public:
Copy(c);
}
template <class InputIterator>
wxVector(InputIterator first, InputIterator last)
: m_size(0), m_capacity(0), m_values(NULL)
{
assign(first, last);
}
~wxVector()
{
clear();
@@ -268,6 +275,19 @@ public:
push_back(v);
}
template <class InputIterator>
void assign(InputIterator first, InputIterator last)
{
clear();
// Notice that it would be nice to call reserve() here but we can't do
// it for arbitrary input iterators, we should have a dispatch on
// iterator type and call it if possible.
for ( InputIterator it = first; it != last; ++it )
push_back(*it);
}
void swap(wxVector& v)
{
wxSwap(m_size, v.m_size);