libRTI/ieee1516-2010/HandleImplementation.cpp | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/libRTI/ieee1516-2010/HandleImplementation.cpp b/libRTI/ieee1516-2010/HandleImplementation.cpp index e5c80a3..21e89d3 100644 --- a/libRTI/ieee1516-2010/HandleImplementation.cpp +++ b/libRTI/ieee1516-2010/HandleImplementation.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "HandleImplementation.h" #include "RTIvariableLengthDataImplementation.h" @@ -82,6 +83,22 @@ bool HandleImplementation::isValid() const return true; } +/* Generate a hash value for use in storing handles in a */ +/* in a hash table. */ +/* Note: The hash value may not be unique across two */ +/* separate handle values but it will be equal given two */ +/* separate instances of the same handle value. */ +/* H1 == H2 implies H1.hash() == H2.hash() */ +/* H1 != H2 does not imply H1.hash() != H2.hash() */ +long HandleImplementation::hash () const +{ + //from + // more details at http://www.cplusplus.com/reference/functional/hash/ + //should think about a non-c++11 approch if needed + std::hash localhash; + return localhash(toString()); +} + /* Generate an encoded value that can be used to send */ /* handles to other federates in updates or interactions. */ VariableLengthData HandleImplementation::encode() const