Website Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
Commit26d3ecce1211b58dbe79302844395c550340d946 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-02 21:35:34 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-02 21:35:34 +0300
Filesad4eb8e0f3652868a36c61495194eafb4888ccad /src
FMI-OOP-P1_TicketSystem-26d3ecce1211b58dbe79302844395c550340d946.tar
FMI-OOP-P1_TicketSystem-26d3ecce1211b58dbe79302844395c550340d946.tar.gz
FMI-OOP-P1_TicketSystem-26d3ecce1211b58dbe79302844395c550340d946.zip
Parent8bb558123dfc6ce90166f34a4324eee2f42b5b8d (diff)
Autocommit at 02.05.2022 @ 21:35
3 files changed, 11 insertions, 0 deletions
-rw-r--r--src/List/List.cpp8
-rw-r--r--src/List/List.h2
-rw-r--r--src/OrderedList/OrderedList.h1
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;
diff --git a/src/OrderedList/OrderedList.h b/src/OrderedList/OrderedList.h
index 17fdc4a..ef723ff 100644
--- a/src/OrderedList/OrderedList.h
+++ b/src/OrderedList/OrderedList.h
@@ -10,6 +10,7 @@ public:
bool insertAt(const T& element, unsigned index) = delete;
bool insert(const T& element);
+ // unsigned findIndex(const T& element) const; TODO: binary search
};
#endif