Word list and hashers to test. More...
Collaboration diagram for ns3::Hash::Example::Dictionary:Public Member Functions | |
| Dictionary () | |
| Constructor. | |
| void | Add (Collider c) |
| Add a Collider containing a hash function. | |
| void | Add (const std::string phrase) |
| Add a string to the dictionary. | |
| void | Report () const |
| Print the collisions for each Collider. | |
| void | ReportExpectedCollisions () const |
| Report the expected number of collisions. | |
| void | Time () |
| Report the execution time of each hash across the entire Dictionary. | |
| void | TimeOne (const Collider &collider) |
| Time and report the execution of one hash across the entire Dictionary. | |
Private Attributes | |
| std::vector< Collider > | m_hashes |
| List of hash Colliders. | |
| unsigned long | m_nphrases |
| Number of strings hashed. | |
| std::vector< std::string > | m_words |
| List of unique words. | |
Word list and hashers to test.
Definition at line 257 of file hash-example.cc.
|
inline |
|
inline |
Add a Collider containing a hash function.
| [in] | c | The Collider to add. |
Definition at line 272 of file hash-example.cc.
References m_hashes.
|
inline |
Add a string to the dictionary.
| [in] | phrase | The string to add. |
Definition at line 282 of file hash-example.cc.
References m_hashes, m_nphrases, and m_words.
|
inline |
Print the collisions for each Collider.
Definition at line 359 of file hash-example.cc.
References m_hashes, and ReportExpectedCollisions().
Here is the call graph for this function:
|
inline |
Report the expected number of collisions.
See, e.g., http://www.math.dartmouth.edu/archive/m19w03/public_html/Section6-5.pdf
![\[ E(collisions) = n - k + k (1 - 1/k)^n
\]](../../form_2.png)
where n is the number of entries in the table, and k is the number of buckets.
This form is numerically unstable for low collision rates. Expanding for large 
![\begin{eqnarray*} E(c) &=& \frac{1}{k} \binom{n}{2}
- \frac{1}{{{k^2}}} \binom{n}{3}
+ \frac{1}{{{k^3}}} \binom{n}{4}
- \ldots \\
&=& \frac{1}{k} \binom{n}{2}
\left[ {1 - \frac{{n - 2}}{{3k}}
+ \frac{{\left( {n - 2} \right)
\left( {n - 3} \right)}}{{12{k^2}}}
- \ldots } \right] \\
&=& \frac{1}{k} \binom{n}{2}
\left\{ {1 - \frac{{n - 2}}{{3k}}
\left[ {1 + \frac{{n - 3}}{{4k}}
- \ldots }
\right]}
\right\}
\end{eqnarray*}](../../form_4.png)
For simplicity, we'll use the first two terms of the second form.
Definition at line 339 of file hash-example.cc.
References m_nphrases.
Referenced by Report().
Here is the caller graph for this function:
|
inline |
Report the execution time of each hash across the entire Dictionary.
Definition at line 398 of file hash-example.cc.
References m_hashes, and TimeOne().
Here is the call graph for this function:
|
inline |
Time and report the execution of one hash across the entire Dictionary.
| [in] | collider | The hash Collider to use. |
Definition at line 374 of file hash-example.cc.
References ns3::Hasher::clear(), ns3::Hasher::GetHash32(), ns3::Hash::Example::Collider::GetName(), ns3::Hash::Example::Collider::m_hash, m_nphrases, and m_words.
Referenced by Time().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
|
private |
Number of strings hashed.
Definition at line 412 of file hash-example.cc.
Referenced by Dictionary(), Add(), ReportExpectedCollisions(), and TimeOne().
|
private |
List of unique words.
Definition at line 414 of file hash-example.cc.
Referenced by Dictionary(), Add(), and TimeOne().