/*
 * ************************************************************************************************************
 * Author: Marcin Załęczny
 * Copyright (C)2010 Marcin Załęczny <mzaleczny@hotmail.com>
 * License: The GNU Lesser General Public License, version 3.0 (LGPLv3)
 * Library Name: mzstd
 * Version: 1.07
 * First release date:   2010-11-08
 * Current release date: 2011-03-04
 *
 *
 * This file is part of mzstd library
 * 
 * mzstd library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * mzstd library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * ************************************************************************************************************
 */

#ifndef __MZSTD_TYPED_ARRAY_LIST_H__
#define __MZSTD_TYPED_ARRAY_LIST_H__

#include "mzstdCommon.h"
#include "mzObject.h"
#include "mzString.h"

class DECLSPEC_MZSTD CTypedArrayListItem : public CObject {
public:
    CString type;
    LONG pointer;

    WINAPI CTypedArrayListItem(CString type, LONG pointer) {
        this->type = type;
        this->pointer = pointer;
        this->setRealClassName(L"CTypedArrayListItem");
    }
    virtual WINAPI ~CTypedArrayListItem() {}
};


class DECLSPEC_MZSTD CTypedArrayList : public CObject {
public:
    WINAPI CTypedArrayList(ULONG capacity = 100);
    virtual WINAPI ~CTypedArrayList();

    VOID WINAPI append(LONG data, CString type);
    inline VOID WINAPI push(LONG data, CString type) { this->append(data, type); };
    VOID WINAPI addAsFirst(LONG data, CString type);
    VOID WINAPI insert(ULONG pos, LONG data, CString type);
    ULONG WINAPI del(LONG data, CString type);
    BOOL WINAPI delFirst(LONG data, CString type);
    BOOL WINAPI delAt(ULONG pos);
    LONG WINAPI pos(LONG data, CString type);
    BOOL WINAPI contains(LONG data, CString type);
    CTypedArrayListItem* WINAPI getAt(ULONG pos);
    VOID WINAPI getAt(ULONG pos, LONG& data, CString& type);
    LONG WINAPI getDataAt(ULONG pos);
    CString WINAPI getTypeAt(ULONG pos);
    CTypedArrayListItem* WINAPI getFirst();
    VOID WINAPI getFirst(LONG& data, CString& type);
    LONG WINAPI getDataAtFirst();
    CString WINAPI getTypeAtFirst();
    CTypedArrayListItem* WINAPI getLast();
    VOID WINAPI getLast(LONG& data, CString& type);
    LONG WINAPI getDataAtLast();
    CString WINAPI getTypeAtLast();
    CTypedArrayListItem* WINAPI pop();
    VOID WINAPI pop(LONG& data);
    VOID WINAPI pop(CString& type);
    VOID WINAPI pop(LONG& data, CString& type);
    inline ULONG WINAPI size() { return this->_size; };
    VOID WINAPI clear();
    inline LONG* WINAPI getItemsBuf() { return this->_items; }
private:
    LONG* _items;
    ULONG _size;
    ULONG _capacity;

    LONG* WINAPI _createNullArray(ULONG capacity);
};
typedef CTypedArrayList* PTypedArrayList;

#endif
