Files
Work/bsptree/Dictionary.hpp
2024-08-16 13:56:19 -04:00

68 lines
1.3 KiB
C++

#ifndef _BSPTREE_DICTIONARY_HPP_
#define _BSPTREE_DICTIONARY_HPP_
#include <bsptree/btree.hpp>
#include <common/block.hpp>
template <class TKey, class TValue>
class Dictionary
{
public:
Dictionary(void);
Dictionary(const Dictionary<TKey, TValue>& someDictionary);
virtual ~Dictionary();
bool containsKey(const TKey& key);
bool insert(const TKey& key, const TValue& value);
TValue operator[](const TKey& key);
Block<TValue> getValues(void)const;
Block<TKey> getKeys(void)const;
private:
template <class TKey, class TValue>
class ItemEntry
{
public:
ItemEntry(void)
{
}
ItemEntry(const TKey& key, const TValue& value)
{
mKey = key;
mValue = value;
}
ItemEntry(const TKey& key)
{
mKey = key;
}
~ItemEntry()
{
}
int operator==(const ItemEntry<TKey, TValue>& item)const
{
return mKey == item.getKey();
}
int operator<(const ItemEntry<TKey, TValue>& item)const
{
return mKey < item.getKey();
}
int operator>(const ItemEntry<TKey, TValue>& item)const
{
return mKey > item.getKey();
}
const TKey& getKey(void)const
{
return (TKey&)mKey;
}
TValue& getValue(void)
{
return mValue;
}
private:
TKey mKey;
TValue mValue;
};
BTree<ItemEntry<TKey, TValue>> data;
};
#include <bsptree/dictionary.tpp>
#endif