 |
BARE2D
|
|
Go to the documentation of this file.
6 #include <unordered_map>
15 template <
typename S,
typename T>
class Cache
60 std::function<T*()> creationFunc = []() -> T* {
return new T(); });
73 typename std::unordered_map<S, T*>::iterator
begin();
74 typename std::unordered_map<S, T*>::iterator
end();
std::unordered_map< S, T * >::iterator begin()
T * findItem(S &key)
Finds an item based on a key.
unsigned int getCount()
Returns the number of items in the cache.
bool addItem(S &key, T *item)
Simply adds an item.
T * createItem(S &key, std::function< T *()> creationFunc=[]() -> T *{ return new T();})
Creates an item with a given key and uses the constructor to fill out the rest. If it already exists,...
std::unordered_map< S, T * > m_data
bool setItem(S &key, T *item)
Adds or overwrites an item.
void clear()
Clears the cache. Destroys all data, calling their respective destructors, then delete.
bool operator!=(Cache &other)
This is a skeleton cache class. This can only be used by the ResourceManager or other classes who act...
std::unordered_map< S, T * >::iterator end()
T * operator[](S &key)
An operator overload that returns the object stored at key. Analagous to findItem();.