Add Hash::clear() to restore initial internal state of hasher
This commit is contained in:
@@ -742,6 +742,11 @@ Fnv1a::GetHash64 (const char * buffer, const size_t size)
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
Fnv1a::clear (void)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace HashFunction
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -52,6 +52,10 @@ public:
|
||||
* \return 64-bit hash of the buffer
|
||||
*/
|
||||
Hash64_t GetHash64 (const char * buffer, const size_t size);
|
||||
/**
|
||||
* Restore initial state
|
||||
*/
|
||||
virtual void clear (void);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -60,6 +60,10 @@ public:
|
||||
* \return 64-bit hash of the buffer
|
||||
*/
|
||||
virtual Hash64_t GetHash64 (const char * buffer, const size_t size);
|
||||
/**
|
||||
* Restore initial state
|
||||
*/
|
||||
virtual void clear (void) = 0;
|
||||
/*
|
||||
* Destructor
|
||||
*/
|
||||
|
||||
@@ -374,6 +374,11 @@ Murmur3::GetHash64 (const char * buffer, const size_t size)
|
||||
return result[0];
|
||||
}
|
||||
|
||||
void
|
||||
Murmur3::clear (void)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace HashFunction
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -61,6 +61,10 @@ public:
|
||||
* \return 64-bit hash of the buffer
|
||||
*/
|
||||
Hash64_t GetHash64 (const char * buffer, const size_t size);
|
||||
/**
|
||||
* Restore initial state
|
||||
*/
|
||||
virtual void clear (void);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -41,5 +41,12 @@ Hash::Hash (Ptr<HashImplementation> hp)
|
||||
{
|
||||
NS_ASSERT (m_impl != 0);
|
||||
}
|
||||
|
||||
|
||||
Hash *
|
||||
Hash::clear (void)
|
||||
{
|
||||
m_impl->clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -104,6 +104,12 @@ public:
|
||||
* \return 64-bit hash of the string
|
||||
*/
|
||||
Hash64_t GetHash64 (const std::string s);
|
||||
/**
|
||||
* Restore initial state
|
||||
*
|
||||
* \return this
|
||||
*/
|
||||
Hash * clear (void);
|
||||
|
||||
private:
|
||||
Ptr<HashImplementation> m_impl; /** Hash implementation */
|
||||
|
||||
Reference in New Issue
Block a user