Website Summary Files Commits Branches @commit @diff @stats
path: root / src / List / List.cpp
diff options
context:
space:
mode:
Commit4e3c2596416f55ffc885ad867e87c86c88e0042e (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-02 21:00:23 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-02 21:00:23 +0300
Files15cee8b61f4048a37395b87d9ffa8d60d4ffa35e /src/List/List.cpp
FMI-OOP-P1_TicketSystem-4e3c2596416f55ffc885ad867e87c86c88e0042e.tar
FMI-OOP-P1_TicketSystem-4e3c2596416f55ffc885ad867e87c86c88e0042e.tar.gz
FMI-OOP-P1_TicketSystem-4e3c2596416f55ffc885ad867e87c86c88e0042e.zip
Parent6fa87ec35f9ee8cd65cfdcb16c31af6dff7911d2 (diff)
Autocommit at 02.05.2022 @ 21:00
1 files changed, 6 insertions, 2 deletions
-rw-r--r--src/List/List.cpp8
diff --git a/src/List/List.cpp b/src/List/List.cpp
index 617bbcf..7236616 100644
--- a/src/List/List.cpp
+++ b/src/List/List.cpp
@@ -43,10 +43,14 @@ void List<T>::add(const T& element) {
template <class T>
bool List<T>::insertAt(const T& element, unsigned index) {
- if (index >= count)
- return add(element);
+ if (index >= count) return add(element);
+ if (length == count) resize();
+ for (unsigned i = count; i > index; i--)
+ elements[i] = elements[i - 1];
+ elements[index] = element;
+ count++;
}
template <class T>