diff --git a/panda/src/putil/buttonHandle.I b/panda/src/putil/buttonHandle.I index 0da0f9a782..59d68ec609 100644 --- a/panda/src/putil/buttonHandle.I +++ b/panda/src/putil/buttonHandle.I @@ -76,6 +76,59 @@ operator < (const ButtonHandle &other) const { return (_index < other._index); } +//////////////////////////////////////////////////////////////////// +// Function: ButtonHandle::Ordering Operator +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool ButtonHandle:: +operator <= (const ButtonHandle &other) const { + return (_index <= other._index); +} + +//////////////////////////////////////////////////////////////////// +// Function: ButtonHandle::Ordering Operator +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool ButtonHandle:: +operator > (const ButtonHandle &other) const { + return (_index > other._index); +} + +//////////////////////////////////////////////////////////////////// +// Function: ButtonHandle::Ordering Operator +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool ButtonHandle:: +operator >= (const ButtonHandle &other) const { + return (_index >= other._index); +} + +//////////////////////////////////////////////////////////////////// +// Function: ButtonHandle::compare_to +// Access: Published +// Description: Sorts ButtonHandles arbitrarily (according to <, >, +// etc.). Returns a number less than 0 if this type +// sorts before the other one, greater than zero if it +// sorts after, 0 if they are equivalent. +//////////////////////////////////////////////////////////////////// +INLINE int ButtonHandle:: +compare_to(const ButtonHandle &other) const { + return _index - other._index; +} + +//////////////////////////////////////////////////////////////////// +// Function: ButtonHandle::get_hash +// Access: Published +// Description: Returns a hash code suitable for phash_map. +//////////////////////////////////////////////////////////////////// +INLINE size_t ButtonHandle:: +get_hash() const { + return (size_t)_index; +} + //////////////////////////////////////////////////////////////////// // Function: ButtonHandle::has_ascii_equivalent // Access: Published diff --git a/panda/src/putil/buttonHandle.h b/panda/src/putil/buttonHandle.h index 3e4a5f0e4d..c53f9a6ac9 100644 --- a/panda/src/putil/buttonHandle.h +++ b/panda/src/putil/buttonHandle.h @@ -29,16 +29,19 @@ class EXPCL_PANDA_PUTIL ButtonHandle { PUBLISHED: INLINE ButtonHandle(); INLINE ButtonHandle(int index); + INLINE ButtonHandle(const ButtonHandle ©); ButtonHandle(const string &name); -public: - INLINE ButtonHandle(const ButtonHandle ©); - +PUBLISHED: INLINE bool operator == (const ButtonHandle &other) const; INLINE bool operator != (const ButtonHandle &other) const; INLINE bool operator < (const ButtonHandle &other) const; + INLINE bool operator <= (const ButtonHandle &other) const; + INLINE bool operator > (const ButtonHandle &other) const; + INLINE bool operator >= (const ButtonHandle &other) const; + INLINE int compare_to(const ButtonHandle &other) const; + INLINE size_t get_hash() const; -PUBLISHED: string get_name() const; INLINE bool has_ascii_equivalent() const; INLINE char get_ascii_equivalent() const;