diff options
Autocommit at 02.05.2022 @ 21:35
2 files changed, 10 insertions, 0 deletions
| -rw-r--r-- | src/List/List.cpp | 8 | ||||
| -rw-r--r-- | src/List/List.h | 2 |
diff --git a/src/List/List.cpp b/src/List/List.cpp index 7236616..d5c2f04 100644 --- a/src/List/List.cpp +++ b/src/List/List.cpp @@ -64,6 +64,14 @@ bool List<T>::removeAt(unsigned index) { } template <class T> +unsigned List<T>::findIndex(const T& element) const { + unsigned ind = 0; + while (ind < count && elements[ind].compare(element) != 0) + ind++; + return ind; +} + +template <class T> T& List<T>::operator[](unsigned index) { return elements[index]; } diff --git a/src/List/List.h b/src/List/List.h index 1068bb7..24003a6 100644 --- a/src/List/List.h +++ b/src/List/List.h @@ -19,6 +19,8 @@ public: void add(const T& element); bool insertAt(const T& element, unsigned index); bool removeAt(unsigned index); + unsigned findIndex(const T& element) const; + bool contains(const T& element) const; T& operator[](unsigned index); const T& operator[](unsigned index) const; |
