Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. template <class HashedObj>
  2. int QuadraticHashTable<HashedObj>::findPos( const HashedObj & x ) const
  3. {
  4. /* 1*/ int collisionNum = 0;
  5. /* 2*/ int currentPos = hash( x.portNum, array.size( ) );
  6.  
  7. /* 3*/ while( array[ currentPos ].info != EMPTY &&
  8. array[ currentPos ].element != x.portNum )
  9. {
  10. /* 4*/ currentPos += 2 * ++collisionNum - 1; // Compute ith probe
  11. /* 5*/ if( currentPos >= array.size( ) )
  12. /* 6*/ currentPos -= array.size( );
  13. }
  14.  
  15. /* 7*/ return currentPos;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement