Browse Source

Added addition get() function to Hash_Table

release/0.19
Jessica James 8 years ago
parent
commit
bce476f03f
  1. 2
      Jupiter/Hash_Table.h
  2. 16
      Jupiter/Hash_Table_Imp.h
  3. 4
      Jupiter/IRC_Client.h

2
Jupiter/Hash_Table.h

@ -70,6 +70,7 @@ namespace Jupiter
* @return Pointer to the value of the entry if it exists, nullptr otherwise
*/
ValueT *get(const InKeyT &in_key) const;
const InValueT &get(const InKeyT &in_key, const InValueT &in_value) const;
/**
* @brief Sets the value for an entry in the bucket
@ -157,6 +158,7 @@ namespace Jupiter
* @return Value of the entry if it exists, nullptr otherwise
*/
ValueT *get(const InKeyT &in_key) const;
const InValueT &get(const InKeyT &in_key, const InValueT &in_value) const;
/**
* @brief Sets the value for an entry in the table

16
Jupiter/Hash_Table_Imp.h

@ -78,6 +78,16 @@ ValueT *Jupiter::Hash_Table<KeyT, ValueT, InKeyT, InValueT, HashF>::Bucket::get(
return nullptr;
}
template<typename KeyT, typename ValueT, typename InKeyT, typename InValueT, size_t(*HashF)(const InKeyT &)>
const InValueT &Jupiter::Hash_Table<KeyT, ValueT, InKeyT, InValueT, HashF>::Bucket::get(const InKeyT &in_key, const InValueT &in_value) const
{
for (Jupiter::SLList<Entry>::Node *node = m_entries.getHead(); node != nullptr; node = node->next)
if (node->data->key == in_key)
return node->data->value;
return in_value;
}
template<typename KeyT, typename ValueT, typename InKeyT, typename InValueT, size_t(*HashF)(const InKeyT &)>
bool Jupiter::Hash_Table<KeyT, ValueT, InKeyT, InValueT, HashF>::Bucket::set(const InKeyT &in_key, const InValueT &in_value)
{
@ -199,6 +209,12 @@ ValueT *Jupiter::Hash_Table<KeyT, ValueT, InKeyT, InValueT, HashF>::get(const In
return m_buckets[HashF(in_key) % m_buckets_size].get(in_key);
}
template<typename KeyT, typename ValueT, typename InKeyT, typename InValueT, size_t(*HashF)(const InKeyT &)>
const InValueT &Jupiter::Hash_Table<KeyT, ValueT, InKeyT, InValueT, HashF>::get(const InKeyT &in_key, const InValueT &in_value) const
{
return m_buckets[HashF(in_key) % m_buckets_size].get(in_key, in_value);
}
template<typename KeyT, typename ValueT, typename InKeyT, typename InValueT, size_t(*HashF)(const InKeyT &)>
bool Jupiter::Hash_Table<KeyT, ValueT, InKeyT, InValueT, HashF>::set(const InKeyT &in_key, const InValueT &in_value)
{

4
Jupiter/IRC_Client.h

@ -884,8 +884,8 @@ namespace Jupiter
/**
* @brief Constructor for a client.
*
* @param in_primary_section INIFile section to search first for a configuration option
* @param in_secondary_section INIFile section to search second for a configuration, before using a pre-defined default value
* @param in_primary_section Config section to search first for a configuration option
* @param in_secondary_section Config section to search second for a configuration, before using a pre-defined default value
*/
Client(const Jupiter::Config *in_primary_section, const Jupiter::Config *in_secondary_section);

Loading…
Cancel
Save