mirror of
https://github.com/jakcron/nstool
synced 2024-12-25 06:01:12 +00:00
[fnd] Add hasElement() to List<T>.
This commit is contained in:
parent
30b3dd6063
commit
cb91fea97f
1 changed files with 21 additions and 0 deletions
|
@ -73,6 +73,27 @@ namespace fnd
|
|||
|
||||
// functions
|
||||
void addElement(const T& element) { mElements.push_back(element); }
|
||||
size_t getIndexOf(const T& element) const
|
||||
{
|
||||
for (size_t i = 0; i < getSize(); i++)
|
||||
{
|
||||
if (getElement(i) == element) return i;
|
||||
}
|
||||
|
||||
throw Exception("LIST", "Element does not exist");
|
||||
}
|
||||
bool hasElement(const T& element) const
|
||||
{
|
||||
try
|
||||
{
|
||||
getIndexOf(element);
|
||||
} catch (const Exception&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
size_t getSize() const { return mElements.size(); }
|
||||
void clear() { mElements.clear(); }
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue