Sign in to follow this  

Complier warning

This topic is 4360 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I have the following class (modified from Data Structures for Game Programmers by Ron Penton) that implements a hash table.
template <class DataType>
struct hash_entry
{
  std::string m_Key;
  DataType m_Data;
};

template <class DataType>
class hash_table
{
  protected:
    int m_Size;
    int m_Count;
    std::vector< std::list< hash_entry<DataType> > > m_Table;
    
    unsigned long int hash(std::string Key);
    
  public:
    hash_table(int p_Size) : m_Size(p_Size), m_Count(0), m_Table(p_Size) { }
    ~hash_table() { m_Size = 0; m_Count = 0; }
    
    void insert(std::string p_Key, DataType p_Data);
    hash_entry<DataType>* find(std::string p_Key);
    void remove(std::string p_Key);
};

Here is the find() function...
template <class DataType>
hash_entry<DataType>* hash_table<DataType>::find(std::string p_Key)
{
  int Index = hash(p_Key) % m_Size;
  std::list< hash_entry<DataType> >::iterator EntryItr = m_Table[Index].begin();
  while(EntryItr != EntryItr.end())
  {
    if((*EntryItr).m_Key == p_Key) { return(&(*EntryItr)); }
    EntryItr++;
  }
  return(NULL);
}

Whenever I compile, I receive the warnings
[Warning] ` std::list<hash_entry<DataType>, std::allocator<hash_entry<DataType> > 
[Warning] implicit typename is  deprecated, please see the documentation for details
Both warnings point to this line in the find() function...
std::list< hash_entry<DataType> >::iterator EntryItr = m_Table[hash(p_Key) % m_Size].begin();
Any idea how to fix this? If you find any other errors / problems, please share those too. Thanks in advance.

Share this post


Link to post
Share on other sites

This topic is 4360 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this