COMMON: Fix SortedArray implementation for empty array
This commit is contained in:
parent
1f8667c5d9
commit
3d89af272b
1 changed files with 5 additions and 0 deletions
|
@ -378,6 +378,11 @@ public:
|
||||||
* Inserts element at the sorted position.
|
* Inserts element at the sorted position.
|
||||||
*/
|
*/
|
||||||
void insert(const T &element) {
|
void insert(const T &element) {
|
||||||
|
if (!this->_size) {
|
||||||
|
this->insert_aux(this->_storage, &element, &element + 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
T *where = (T *)bsearchMin(element, this->front(), this->_size, sizeof(T), _comparator);
|
T *where = (T *)bsearchMin(element, this->front(), this->_size, sizeof(T), _comparator);
|
||||||
insert(where, element);
|
insert(where, element);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue