#include <dict.h>
#include <string.h>
#include <stdlib.h>
template<typename T>
Dict<T>::Dict() : Iterable<T>()
{
keys = 0;
}
template<typename T>
Dict<T>::~Dict()
{
if (keys)
for (int i = 0; i < this->cnt; i++)
free(keys[i]);
free(keys);
}
template<typename T>
void Dict<T>::append(const char *key, T item)
{
this->cnt++;
keys = (char **)realloc(keys, sizeof(char *) * this->cnt);
this->items = (T*)realloc(this->items, sizeof(T) * this->cnt);
keys[this->cnt - 1] = strdup(key);
this->items[this->cnt - 1] = item;
}