From aa8b39d1ea473224ab7b52aaf580201fbc1dfbbf Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 2 May 2022 22:00:43 +0300 Subject: Autocommit at 02.05.2022 @ 22:00 --- List/OrderedList.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 List/OrderedList.cpp (limited to 'List/OrderedList.cpp') diff --git a/List/OrderedList.cpp b/List/OrderedList.cpp new file mode 100644 index 0000000..f3a7450 --- /dev/null +++ b/List/OrderedList.cpp @@ -0,0 +1,12 @@ +#include "OrderedList.h" + +template +bool OrderedList::insert(const T& element) { + if (List::length == List::count) List::resize(); + + unsigned insertionInd = 0; + while (List::elements[insertionInd].compare(element) < 0 && insertionInd < List::count) + insertionInd++; + + return List::insertAt(element, insertionInd); +} -- cgit v1.3.1-23-gd82d