ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • TBaseList
    C++ Builder/Class 2018. 12. 6. 22:50

    template <class T> class TBaseList : public TList

    {

    private:

    protected:

    T* __fastcall   GetItems(int Index);

    public:

    __fastcall   TBaseList();

    __fastcall   ~TBaseList();

    public:

    int  __fastcall Add(T *Item);

    void __fastcall Delete(int Index, bool Flag = true);

    void __fastcall Clear();

    int  __fastcall IndexOf(T *Item);

    public:

    __property T* Items[int iIndex] = { read = GetItems };

    };

    //---------------------------------------------------------------------------

    template <class T> __fastcall TBaseList<T>::TBaseList()

    : TList()

    {

    }

    //---------------------------------------------------------------------------

    template <class T> __fastcall TBaseList<T>::~TBaseList()

    {

    Clear();

    }

    //---------------------------------------------------------------------------

    template <class T> int  __fastcall TBaseList<T>::Add(T *Item)

    {

    return TList::Add( (void*)Item );

    }

    //---------------------------------------------------------------------------

    template <class T> void __fastcall TBaseList<T>::Delete(int Index, bool Flag)

    {

    T *Item;


    if(Index < 0 || Index >= Count) return;

    if(Flag){

    Item = (T*)TList::Items[Index];

    delete Item;

    }

    TList::Delete(Index);

    }

    //---------------------------------------------------------------------------

    template <class T> void __fastcall TBaseList<T>::Clear()

    {

    while(Count) Delete(0);

    TList::Clear();

    }

    //---------------------------------------------------------------------------

    template <class T> int  __fastcall TBaseList<T>::IndexOf(T *Item)

    {

    return TList::IndexOf((void*)Item);

    }

    //---------------------------------------------------------------------------

    template <class T> T* __fastcall TBaseList<T>::GetItems(int Index)

    {

    return (T*)TList::Items[Index];

    }



    728x90

    'C++ Builder > Class' 카테고리의 다른 글

    TThread  (0) 2019.01.30
    TIniFile  (0) 2019.01.25
    TString  (0) 2018.12.06

    댓글

Designed by Tistory.