AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
aud.example.hash.HashtableExample.LinearProbing< T > Class Template Reference

Collision handling by linear probing h(x,i)=h(x)+i*b
More...

+ Inheritance diagram for aud.example.hash.HashtableExample.LinearProbing< T >:
+ Collaboration diagram for aud.example.hash.HashtableExample.LinearProbing< T >:

Public Member Functions

 LinearProbing ()
 
 LinearProbing (int b)
 
long newHash (SimpleHashtable< T > table, T key, long h, int count)
 Handle collision by computing a new hash value. More...
 
String toString ()
 
abstract long newHash (SimpleHashtable< T > table, T key, long h, int count)
 Handle collision by computing a new hash value. More...
 

Detailed Description

Collision handling by linear probing h(x,i)=h(x)+i*b

Definition at line 84 of file HashtableExample.java.

Constructor & Destructor Documentation

◆ LinearProbing() [1/2]

◆ LinearProbing() [2/2]

Definition at line 87 of file HashtableExample.java.

87 {
88 this();
89 assert(b>0);
90 b_=b;
91 }

Member Function Documentation

◆ newHash()

long aud.example.hash.HashtableExample.LinearProbing< T >.newHash ( SimpleHashtable< T >  table,
key,
long  h,
int  count 
)

Handle collision by computing a new hash value.

Parameters
tablehash table
keynew entry that is to be inserted but caused the collision
hpreviously used hash value
countiteration count for collision handling starting with 1 (=first collision)
Returns
new hash value

Reimplemented from aud.example.hash.CollisionHandler< T >.

Definition at line 94 of file HashtableExample.java.

94 {
95 return h+count*b_;
96 }

◆ toString()

Definition at line 98 of file HashtableExample.java.

98 {
99 return "LinearProbing[b="+b_+"]";
100 }

The documentation for this class was generated from the following file: