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 64 of file bitmap.cpp.

Member Typedef Documentation

◆ argument_type

Definition at line 66 of file bitmap.cpp.

◆ result_type

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

Definition at line 67 of file bitmap.cpp.

Member Function Documentation

◆ operator()()

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

Definition at line 69 of file bitmap.cpp.

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

References scale.


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