mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-25 17:15:45 +08:00
Also add wxObjArray::swap() for consistency with the other arrays
As with the previous commit, make this kind of arrays a bit more comfortable to use as long as we can't avoid using them completely.
This commit is contained in:
@@ -436,6 +436,8 @@ public:
|
||||
|
||||
void Sort(CMPFUNC fCmp) { base::Sort(fCmp); }
|
||||
|
||||
void swap(wxBaseObjectArray& other) { base::swap(other); }
|
||||
|
||||
// Provide a way to iterate over the stored objects using range-based for.
|
||||
class ObjectIterator
|
||||
{
|
||||
|
||||
@@ -616,6 +616,15 @@ TEST_CASE("wxObjArray", "[dynarray]")
|
||||
CHECK( bars.GetCount() == 3 );
|
||||
CHECK( Bar::GetNumber() == 4 );
|
||||
|
||||
ArrayBars tmp;
|
||||
bars.swap(tmp);
|
||||
CHECK( bars.size() == 0 );
|
||||
CHECK( Bar::GetNumber() == 4 );
|
||||
|
||||
bars.swap(tmp);
|
||||
CHECK( bars.size() == 3 );
|
||||
CHECK( Bar::GetNumber() == 4 );
|
||||
|
||||
bars.RemoveAt(1, bars.GetCount() - 1);
|
||||
|
||||
CHECK( bars.GetCount() == 1 );
|
||||
|
||||
Reference in New Issue
Block a user