diff options
Autocommit at 02.05.2022 @ 21:00
2 files changed, 6 insertions, 2 deletions
| -rw-r--r-- | src/.!lazygit.swo | bin | 24576 -> 24576 bytes | |||
| -rw-r--r-- | src/List/List.cpp | 8 |
diff --git a/src/.!lazygit.swo b/src/.!lazygit.swo Binary files differindex 510dcb8..6d503e2 100644 --- a/src/.!lazygit.swo +++ b/src/.!lazygit.swo 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> |
