Add the reserve() method to FListBox to increase the capacity of the list

This commit is contained in:
Markus Gans 2019-04-27 00:38:15 +02:00
parent cc720dc7db
commit ec502d208a
3 changed files with 9 additions and 0 deletions

View File

@ -1,3 +1,6 @@
2019-04-27 Markus Gans <guru.mail@muenster.de>
* Add the reserve() method to FListBox to increase the capacity of the list
2019-03-24 Markus Gans <guru.mail@muenster.de> 2019-03-24 Markus Gans <guru.mail@muenster.de>
* Add a "scroll view" chapter to the first steps document * Add a "scroll view" chapter to the first steps document

View File

@ -568,6 +568,7 @@ void MyDialog::initWidgets()
myList.setText ("Items"); myList.setText ("Items");
myList.setStatusbarMessage ("99 items in a list"); myList.setStatusbarMessage ("99 items in a list");
myList.setMultiSelection(); myList.setMultiSelection();
myList.reserve(100);
for (int z = 1; z < 100; z++) for (int z = 1; z < 100; z++)
myList.insert (finalcut::FString() << z << L" placeholder"); myList.insert (finalcut::FString() << z << L" placeholder");

View File

@ -221,6 +221,7 @@ class FListBox : public FWidget
, bool = false , bool = false
, FDataPtr = nullptr ); , FDataPtr = nullptr );
void remove (std::size_t); void remove (std::size_t);
void reserve (std::size_t);
void clear(); void clear();
// Event handlers // Event handlers
@ -471,6 +472,10 @@ inline bool FListBox::hasBrackets(std::size_t index)
inline bool FListBox::hasBrackets(listBoxItems::iterator iter) const inline bool FListBox::hasBrackets(listBoxItems::iterator iter) const
{ return bool(iter->brackets > 0); } { return bool(iter->brackets > 0); }
//----------------------------------------------------------------------
inline void FListBox::reserve (std::size_t new_cap)
{ itemlist.reserve(new_cap); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template <typename Iterator, typename InsertConverter> template <typename Iterator, typename InsertConverter>
inline void FListBox::insert ( Iterator first inline void FListBox::insert ( Iterator first