#ifndef __MZSTD_OBJECT_LIST_H__
#define __MZSTD_OBJECT_LIST_H__

#include "mzstdCommon.h"
#include "mzObject.h"
#include "mzPointerList.h"

namespace mzstd {

class DECLSPEC_MZSTD CmzObjectList : public CmzPointerList {
public:
    WINAPI CmzObjectList(ULONG capacity = 50, BOOL deleteObjects = TRUE);
    virtual WINAPI ~CmzObjectList();

    VOID WINAPI append(CmzObject* data);
    VOID WINAPI append(CmzObjectList* lst);
    inline VOID WINAPI push(CmzObject* data) { this->append(data); };
    VOID WINAPI addAsFirst(CmzObject* data);
    VOID WINAPI insert(ULONG pos, CmzObject* data);
    // Removes objects from array and deletes it.
    ULONG WINAPI del(CmzObject* data);
    // Removes first object from array and deletes it.
    BOOL WINAPI delFirst(CmzObject* data);
    // Removes object from array and deletes it.
    BOOL WINAPI delAt(ULONG pos);
    // Removes objects from array.
    ULONG WINAPI remove(CmzObject* data);
    // Removes first object from array. Returns the object.
    BOOL WINAPI removeFirst(CmzObject* data);
    // Removes object from array. Returns the object.
    CmzObject* WINAPI removeAt(ULONG pos);
    LONG WINAPI pos(CmzObject* data);
    BOOL WINAPI contains(CmzObject* data);
    inline CmzObject* WINAPI getAt(ULONG pos) { if (pos < this->_size) return (CmzObject*)this->_items[pos]; return NULL; };
    VOID WINAPI setAt(ULONG pos, CmzObject* data);
	inline CmzObject* WINAPI getLast() { if (this->_size > 0) return (CmzObject*)this->_items[this->_size - 1]; return NULL; };
    CmzObject* WINAPI pop();
    // removes all object in the list and delete them
    virtual VOID WINAPI clear();
    // removes all object in the list but do not delete them
    virtual VOID WINAPI empty();

    virtual CmzString WINAPI toString();
    
protected:
    // Sometimes we hold the same objects (pointers to them) in a few arrays and do not want release them
    // when the array is deleted.
    BOOL _deleteObjectsInDestructor;
};

}

#endif
