diff --git a/Collection/SortedArray.mqh b/Collection/SortedArray.mqh index 07ef5b2..2454161 100644 --- a/Collection/SortedArray.mqh +++ b/Collection/SortedArray.mqh @@ -39,11 +39,11 @@ public: // owned: flag restricts destructor to delete array elements // unique: flag allows add()-ing of identical elements // sorter: array sorting implementation - SortedArray(bool owned=true,bool unique=true,SortComparer*sorter=NULL): + SortedArray(SortComparer*sorter,bool owned=true,bool unique=true): Collection(owned,sorter), m_unique(unique), - m_sorter(sorter==NULL?new GenericSortComparer():sorter){} - ~SortedArray() {SafeDelete(m_sorter);} + m_sorter(sorter){} + ~SortedArray() {clear();} // ConstIterator interface ConstIterator*constIterator() const {return new ConstSortedArrayIterator(GetPointer(this));} @@ -51,7 +51,7 @@ public: Iterator*iterator() {return new SortedArrayIterator(GetPointer(this),m_owned);} // Collection interface - void clear() {m_array.clear();} + void clear() {if(m_owned) m_array.clear(); else m_array.resize(0);} bool add(T value); bool remove(const T value); int size() const {return m_array.size();}