A Discrete-Event Network Simulator
API
ns3::Hash::Example::Collider Class Reference

Keep track of collisions. More...

+ Collaboration diagram for ns3::Hash::Example::Collider:

Public Types

enum  Bits { Bits32 , Bits64 }
 The size of hash function being tested. More...
 

Public Member Functions

 Collider (const std::string name, Hasher hash, const Bits bits)
 Constructor. More...
 
bool Add (const std::string phrase)
 Add a string to the Collider. More...
 
std::string GetName () const
 
void Report () const
 Print the collisions found. More...
 

Public Attributes

Hasher m_hash
 The hash. More...
 
std::string m_name
 Name of this hash. More...
 

Private Types

typedef std::vector< std::pair< uint64_t, std::string > > collision_t
 Collision map of subsequent instances. More...
 
typedef std::map< uint64_t, std::string > hashdict_t
 Hashed dictionary of first instance of each hash. More...
 

Private Member Functions

uint64_t GetHash (const std::string phrase)
 Get the appropriate hash value. More...
 

Private Attributes

Bits m_bits
 Hash function. More...
 
collision_t m_coll
 The list of collisions. More...
 
hashdict_t m_dict
 The dictionary map, indexed by hash. More...
 

Detailed Description

Keep track of collisions.

Definition at line 120 of file hash-example.cc.

Member Typedef Documentation

◆ collision_t

typedef std::vector<std::pair<uint64_t, std::string> > ns3::Hash::Example::Collider::collision_t
private

Collision map of subsequent instances.

Definition at line 257 of file hash-example.cc.

◆ hashdict_t

typedef std::map<uint64_t, std::string> ns3::Hash::Example::Collider::hashdict_t
private

Hashed dictionary of first instance of each hash.

Definition at line 251 of file hash-example.cc.

Member Enumeration Documentation

◆ Bits

The size of hash function being tested.

Enumerator
Bits32 

Use 32-bit hash function.

Bits64 

Use 64-bit hash function.

Definition at line 127 of file hash-example.cc.

Constructor & Destructor Documentation

◆ Collider()

ns3::Hash::Example::Collider::Collider ( const std::string  name,
Hasher  hash,
const Bits  bits 
)
inline

Constructor.

Parameters
[in]nameHash function name.
[in]hashHash function.
[in]bitsWhich hash length to use.

Definition at line 140 of file hash-example.cc.

Member Function Documentation

◆ Add()

bool ns3::Hash::Example::Collider::Add ( const std::string  phrase)
inline

Add a string to the Collider.

Parameters
[in]phraseThe string to add.
Returns
true If this was a new string.

Definition at line 153 of file hash-example.cc.

References GetHash(), m_coll, and m_dict.

+ Here is the call graph for this function:

◆ GetHash()

uint64_t ns3::Hash::Example::Collider::GetHash ( const std::string  phrase)
inlineprivate

Get the appropriate hash value.

Parameters
[in]phraseThe string to hash.
Returns
The hash value, using the number of bits set in the constructor.

Definition at line 231 of file hash-example.cc.

References Bits32, ns3::Hasher::clear(), ns3::Hasher::GetHash32(), ns3::Hasher::GetHash64(), m_bits, and m_hash.

Referenced by Add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetName()

std::string ns3::Hash::Example::Collider::GetName ( ) const
inline
Returns
The hash name, including the length.

Definition at line 190 of file hash-example.cc.

References Bits32, Bits64, m_bits, and m_name.

Referenced by Report(), and ns3::Hash::Example::Dictionary::TimeOne().

+ Here is the caller graph for this function:

◆ Report()

void ns3::Hash::Example::Collider::Report ( ) const
inline

Print the collisions found.

Definition at line 209 of file hash-example.cc.

References GetName(), m_coll, and m_dict.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_bits

Bits ns3::Hash::Example::Collider::m_bits
private

Hash function.

Definition at line 248 of file hash-example.cc.

Referenced by GetHash(), and GetName().

◆ m_coll

collision_t ns3::Hash::Example::Collider::m_coll
private

The list of collisions.

Definition at line 260 of file hash-example.cc.

Referenced by Add(), and Report().

◆ m_dict

hashdict_t ns3::Hash::Example::Collider::m_dict
private

The dictionary map, indexed by hash.

Definition at line 254 of file hash-example.cc.

Referenced by Add(), and Report().

◆ m_hash

Hasher ns3::Hash::Example::Collider::m_hash

The hash.

Definition at line 124 of file hash-example.cc.

Referenced by GetHash(), and ns3::Hash::Example::Dictionary::TimeOne().

◆ m_name

std::string ns3::Hash::Example::Collider::m_name

Name of this hash.

Definition at line 123 of file hash-example.cc.

Referenced by GetName().


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