KiCad PCB EDA Suite
std::hash< SCALED_BITMAP_ID > Struct Template Reference

Public Types

typedef SCALED_BITMAP_ID argument_type
 
typedef std::size_t result_type
 

Public Member Functions

result_type operator() (argument_type const &id) const noexcept
 

Detailed Description

template<>
struct std::hash< SCALED_BITMAP_ID >

Definition at line 56 of file bitmap.cpp.

Member Typedef Documentation

Definition at line 58 of file bitmap.cpp.

typedef std::size_t std::hash< SCALED_BITMAP_ID >::result_type

Definition at line 59 of file bitmap.cpp.

Member Function Documentation

result_type std::hash< SCALED_BITMAP_ID >::operator() ( argument_type const &  id) const
inlinenoexcept

Definition at line 61 of file bitmap.cpp.

References SCALED_BITMAP_ID::scale.

62  {
63  static const bool sz64 = sizeof( uintptr_t ) == 8;
64  static const size_t mask = sz64 ? 0xF000000000000000uLL : 0xF0000000uL;
65  static const size_t offset = sz64 ? 60 : 28;
66 
67  // The hash only needs to be fast and simple, not necessarily accurate - a collision
68  // only makes things slower, not broken. BITMAP_DEF is a pointer, so the most
69  // significant several bits are generally going to be the same for all. Just convert
70  // it to an integer and stuff the scale factor into those bits.
71  return
72  ( (uintptr_t)( id.bitmap ) & ~mask ) |
73  ( ( (uintptr_t)( id.scale ) & 0xF ) << offset );
74  }
const int scale

The documentation for this struct was generated from the following file: