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

81 lines
1.7 KiB
C++

#ifndef _BSPTREE_DICTIONARY_HPP_
#error DICTIONARY.HPP must precede DICTIONARY.TPP
#endif
template <class TKey, class TValue>
inline
Dictionary<TKey, TValue>::Dictionary(void)
{
}
template <class TKey, class TValue>
inline
Dictionary<TKey, TValue>::Dictionary(const Dictionary<TKey, TValue>& someDictionary)
{
throw;
}
template <class TKey, class TValue>
inline
Dictionary<TKey, TValue>::~Dictionary()
{
}
template <class TKey, class TValue>
inline
bool Dictionary<TKey, TValue>::containsKey(const TKey& key)
{
ItemEntry<TKey, TValue> item(key);
return data.find(item);
}
template <class TKey, class TValue>
inline
bool Dictionary<TKey, TValue>::insert(const TKey& key, const TValue& value)
{
ItemEntry<TKey, TValue> item(key, value);
if (data.find(item))throw;
data.insert(item);
return true;
}
template <class TKey, class TValue>
inline
Block<TValue> Dictionary<TKey, TValue>::getValues(void)const
{
Block<ItemEntry<TKey, TValue>> items = Block<ItemEntry<TKey, TValue>>();
Block<TValue> values = Block<TValue>();
data.treeItems(items);
for (int index = 0;index < items.size();index++)
{
values.insert(&items[index].getValue());
}
return values;
}
template <class TKey, class TValue>
inline
Block<TKey> Dictionary<TKey, TValue>::getKeys(void)const
{
Block<ItemEntry<TKey, TValue>> items = Block<ItemEntry<TKey, TValue>>();
Block<TKey> keys = Block<TKey>();
data.treeItems(items);
for (int index = 0;index < items.size();index++)
{
keys.insert(&items[index].getKey());
}
return keys;
}
template <class TKey, class TValue>
inline
TValue Dictionary<TKey, TValue>::operator[](const TKey& key)
{
ItemEntry<TKey, TValue> item(key);
if (!data.find(item))throw;
return item.getValue();
}
#pragma once