mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-22 10:45:28 +00:00
[fnd] Add hasElement() to List<T>.
This commit is contained in:
parent
30b3dd6063
commit
cb91fea97f
|
@ -73,6 +73,27 @@ namespace fnd
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
void addElement(const T& element) { mElements.push_back(element); }
|
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(); }
|
size_t getSize() const { return mElements.size(); }
|
||||||
void clear() { mElements.clear(); }
|
void clear() { mElements.clear(); }
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue