/* * Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _LIST_H #define _LIST_H #include #include template class List { public: uint32 CountItems() const; void AddItem(T type); void RemoveItemAt(uint32 position); T ItemAt(uint32 position); void AddList(List appendList); private: std::list fList; typedef typename std::list::iterator fIter; }; template uint32 List::CountItems() const { return fList.size(); } template void List::AddItem(T type) { fList.push_back(type); } template void List::RemoveItemAt(uint32 position) { fIter i = fList.begin(); std::advance(i, position); fList.erase(i); } template T List::ItemAt(uint32 position) { fIter i = fList.begin(); std::advance(i, position); return *i; } template void List::AddList(List appendList) { if (appendList.CountItems() == 0) return; for (int i = 0; i < appendList.CountItems(); i++) AddItem(appendList.ItemAt(i)); } #endif // _LIST_H