Website Summary Files Commits Branches @commit @diff @stats
path: root / src / List / OrderedList.cpp
blob: 7476574632cc23bc3e02286b4da2fa3dc5c970ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "OrderedList.h"

template <class T>
OrderedList<T>::OrderedList() : OrderedList(nullptr, 0) {}

template <class T>
OrderedList<T>::OrderedList(const T* elements, unsigned elementsCount) : List<T>::List(elements, elementsCount) {}

template <class T>
bool OrderedList<T>::insert(const T& element) {
	if (List<T>::length == List<T>::count) List<T>::resize();

	unsigned insertionInd = 0;
	while (List<T>::elements[insertionInd].compare(element) < 0 && insertionInd < List<T>::count)
		insertionInd++;

	return List<T>::insertAt(element, insertionInd);
}