Add Hash::clear() to restore initial internal state of hasher hash
authorPeter D. Barnes, Jr. <barnes26@llnl.gov>
Tue, 13 Nov 2012 16:35:21 -0800
branchhash
changeset 9930 0268fa8576c0
parent 9929 3e8510caf03a
child 9931 a3edc13a84f3
Add Hash::clear() to restore initial internal state of hasher
src/core/model/hash-fnv.cc
src/core/model/hash-fnv.h
src/core/model/hash-implementation.h
src/core/model/hash-murmur3.cc
src/core/model/hash-murmur3.h
src/core/model/hash.cc
src/core/model/hash.h
src/lte/model/lte-radio-bearer-tag.cc
src/lte/model/lte-radio-bearer-tag.h
src/lte/model/lte-rlc-um.cc
src/lte/model/lte-rlc-um.h
--- a/src/core/model/hash-fnv.cc	Tue Nov 13 16:34:34 2012 -0800
+++ b/src/core/model/hash-fnv.cc	Tue Nov 13 16:35:21 2012 -0800
@@ -742,6 +742,11 @@
   return result;
 }
       
+void
+Fnv1a::clear (void)
+{
+}
+
   }  // namespace HashFunction
   
 } // namespace ns3
--- a/src/core/model/hash-fnv.h	Tue Nov 13 16:34:34 2012 -0800
+++ b/src/core/model/hash-fnv.h	Tue Nov 13 16:35:21 2012 -0800
@@ -52,6 +52,10 @@
    * \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:
   /**
--- a/src/core/model/hash-implementation.h	Tue Nov 13 16:34:34 2012 -0800
+++ b/src/core/model/hash-implementation.h	Tue Nov 13 16:35:21 2012 -0800
@@ -60,6 +60,10 @@
    * \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
    */
--- a/src/core/model/hash-murmur3.cc	Tue Nov 13 16:34:34 2012 -0800
+++ b/src/core/model/hash-murmur3.cc	Tue Nov 13 16:35:21 2012 -0800
@@ -374,6 +374,11 @@
   return result[0];
 }
 
+void
+Murmur3::clear (void)
+{
+}
+
   }  // namespace HashFunction
   
 } // namespace ns3
--- a/src/core/model/hash-murmur3.h	Tue Nov 13 16:34:34 2012 -0800
+++ b/src/core/model/hash-murmur3.h	Tue Nov 13 16:35:21 2012 -0800
@@ -61,6 +61,10 @@
    * \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:
   /**
--- a/src/core/model/hash.cc	Tue Nov 13 16:34:34 2012 -0800
+++ b/src/core/model/hash.cc	Tue Nov 13 16:35:21 2012 -0800
@@ -41,5 +41,12 @@
 {
   NS_ASSERT (m_impl != 0);
 }
-  
+
+Hash *
+Hash::clear (void)
+{
+  m_impl->clear();
+  return this;
+}
+
 } // namespace ns3
--- a/src/core/model/hash.h	Tue Nov 13 16:34:34 2012 -0800
+++ b/src/core/model/hash.h	Tue Nov 13 16:35:21 2012 -0800
@@ -104,6 +104,12 @@
    * \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 */