Browse Source

add get_key() method for Python hashing

David Rose 18 years ago
parent
commit
490d24ef41
2 changed files with 14 additions and 0 deletions
  1. 12 0
      panda/src/putil/bitMask.I
  2. 2 0
      panda/src/putil/bitMask.h

+ 12 - 0
panda/src/putil/bitMask.I

@@ -699,6 +699,18 @@ operator >>= (int shift) {
   _word >>= shift;
   _word >>= shift;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: BitMask::get_key
+//       Access: Published
+//  Description: Returns a mostly unique integer key per unique
+//               bitmask, suitable for using in a hash table.
+////////////////////////////////////////////////////////////////////
+template<class WType, int nbits>
+INLINE int BitMask<WType, nbits>::
+get_key() const {
+  return (int)_word;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: BitMask::generate_hash
 //     Function: BitMask::generate_hash
 //       Access: Public
 //       Access: Public

+ 2 - 0
panda/src/putil/bitMask.h

@@ -114,6 +114,8 @@ PUBLISHED:
   INLINE void operator <<= (int shift);
   INLINE void operator <<= (int shift);
   INLINE void operator >>= (int shift);
   INLINE void operator >>= (int shift);
 
 
+  INLINE int get_key() const;
+
 public:
 public:
   INLINE void generate_hash(ChecksumHashGenerator &hashgen) const;
   INLINE void generate_hash(ChecksumHashGenerator &hashgen) const;