/*
 * ************************************************************************************************************
 * 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_LINK_LIST_H__
#define __MZSTD_LINK_LIST_H__

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

class DECLSPEC_MZSTD CLinkListNode : public CObject {
public:
    LONG data;
    CLinkListNode* next;
};
typedef CLinkListNode* PLinkListNode;

class DECLSPEC_MZSTD CLinkList : public CObject {
public:
    WINAPI CLinkList();
    WINAPI ~CLinkList();

    VOID WINAPI append(LONG data);
    inline VOID WINAPI push(LONG data) { this->append(data); }
    LONG WINAPI pop();
    VOID WINAPI addAsFirst(LONG data);
    VOID WINAPI addAfter(ULONG pos, LONG data);
    ULONG WINAPI del(LONG data);
    BOOL WINAPI delFirst(LONG data);
    BOOL WINAPI del(ULONG pos);
    LONG WINAPI getAt(ULONG pos);
    LONG WINAPI pos(LONG data);
    BOOL WINAPI contains(LONG data);
    inline ULONG WINAPI size() { return this->_size; };
    inline CLinkListNode* WINAPI first() { return this->_head; }
    inline CLinkListNode* WINAPI lastNode() { return this->_last; }
    VOID WINAPI clear();
private:
    CLinkListNode *_head;
    CLinkListNode *_last;
    ULONG _size;
};
typedef CLinkList *PLinkList;

#endif
