From 4e3c2596416f55ffc885ad867e87c86c88e0042e Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 2 May 2022 21:00:23 +0300 Subject: Autocommit at 02.05.2022 @ 21:00 --- src/.!lazygit.swo | Bin 24576 -> 24576 bytes src/List/List.cpp | 8 ++++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/.!lazygit.swo b/src/.!lazygit.swo index 510dcb8..6d503e2 100644 Binary files a/src/.!lazygit.swo and b/src/.!lazygit.swo differ 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::add(const T& element) { template bool List::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 -- cgit v1.3.1-25-gf783