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

Member Typedef Documentation

Definition at line 57 of file bitmap.cpp.

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

Definition at line 58 of file bitmap.cpp.

Member Function Documentation

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

Definition at line 60 of file bitmap.cpp.

References SCALED_BITMAP_ID::scale.

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

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