10template<
typename S,
typename O =
void>
35 ssize_t
add(
const S& text, O*
object =
nullptr);
44 ssize_t
addAt(ssize_t index,
const S& text, O*
object =
nullptr);
92 const S&
at(ssize_t index)
const;
143 bool find(
const S& text, ssize_t& index)
const;
153 void quickSort(ssize_t left, ssize_t right, std::function<
bool(
const Item&,
const Item&)> comp);
158 std::vector<Item> _items;
177#include <misc/gen/TStringList.hpp>
String list with optional object association and sorting.
Definition TStringList.h:12
O * objectAt(ssize_t index) const
Gets the associated object at index.
const S & at(ssize_t index) const
Returns the string at index.
void setObject(ssize_t index, O *obj)
Sets the object at index.
ssize_t count() const
Returns the number of items.
void setSorted(bool flag=true)
Sorts the list and sets a flag so the new entries are sorted as well.
ssize_t indexOf(const S &text) const
Returns the index of the string.
std::function< void(void *)> onChanging
Event handler before the list changes.
Definition TStringList.h:128
void exchange(ssize_t i, ssize_t j)
Exchanges two items.
void beginChange()
Prevents calling onChanging and onChanged when modifying. Call this before updating or adding multipl...
bool isSorted() const
Whether the list is sorted.
void endChange()
Prevents calling onChanging and onChanged when modifying. Call this after updating or adding multiple...
std::function< void(void *)> onChanged
Event handler when the list has changed.
Definition TStringList.h:123
ssize_t add(const S &text, O *object=nullptr)
Adds a string to the list.
~TStringList()
Destroys the string list and releases resources.
void removeAt(ssize_t index)
Deletes the item at the given index.
void clear()
Clears all items from the list.
TStringList()
Constructs a list not allowing duplicates by default.
ssize_t addAt(ssize_t index, const S &text, O *object=nullptr)
Inserts a string at the given index but when sorting it is calling add() instead.
TStringList(bool duplicates, bool sorted)
Constructs a list configuring duplicate behavior and sorting.
Definition Application.h:10