Add Hash::clear() to restore initial internal state of hasher

This commit is contained in:
Peter D. Barnes, Jr.
2012-11-13 16:35:21 -08:00
parent 94d417c60f
commit 674f613678
7 changed files with 36 additions and 1 deletions

View File

@@ -742,6 +742,11 @@ Fnv1a::GetHash64 (const char * buffer, const size_t size)
return result;
}
void
Fnv1a::clear (void)
{
}
} // namespace HashFunction
} // namespace ns3

View File

@@ -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:
/**

View File

@@ -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
*/

View File

@@ -374,6 +374,11 @@ Murmur3::GetHash64 (const char * buffer, const size_t size)
return result[0];
}
void
Murmur3::clear (void)
{
}
} // namespace HashFunction
} // namespace ns3

View File

@@ -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:
/**

View File

@@ -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

View File

@@ -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 */