Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class KeyType, class DataType>
- void HASHTABLE<KeyType,DataType>::insert(const KeyType& key, const DataType& data)
- {
- int insert;
- if ( find( key, insert) )
- m_data[insert] = data;
- else
- {
- if ( COLLECTION<DataType>::m_size == m_capacity )
- throw std::length_error( "HASHTABLE is full, dude!" );
- insert = hash( key );
- int counter = 0;
- while ( m_key[insert] == CURRENTLY_FILLED && counter < m_capacity)
- {
- insert = ( insert + 1 ) % m_capacity;
- counter++;
- }
- m_key_store[insert] = key;
- m_key[insert] = CURRENTLY_FILLED;
- m_data[insert] = data;
- COLLECTION<DataType>::m_size++;
- }
- }
Add Comment
Please, Sign In to add comment