KiCad PCB EDA Suite
Loading...
Searching...
No Matches
hashtables.h File Reference
#include <unordered_map>
#include <wx/string.h>

Go to the source code of this file.

Classes

struct  iequal_to
 Equality test for "const char*" type used in very specialized KEYWORD_MAP below. More...
 
struct  fnv_1a
 Very fast and efficient hash function for "const char*" type, used in specialized KEYWORD_MAP below. More...
 

Macros

#define DECL_HASH_FOR_SWIG(TypeName, KeyType, ValueType)    typedef std::unordered_map<KeyType, ValueType> TypeName;
 Declare a std::unordered_map but no swig template.
 

Typedefs

typedef std::unordered_map< const char *, int, fnv_1a, iequal_toKEYWORD_MAP
 A hashtable made of a const char* and an int.
 

Macro Definition Documentation

◆ DECL_HASH_FOR_SWIG

#define DECL_HASH_FOR_SWIG (   TypeName,
  KeyType,
  ValueType 
)     typedef std::unordered_map<KeyType, ValueType> TypeName;

Declare a std::unordered_map but no swig template.

Definition at line 73 of file hashtables.h.

Typedef Documentation

◆ KEYWORD_MAP

typedef std::unordered_map< const char*, int, fnv_1a, iequal_to > KEYWORD_MAP

A hashtable made of a const char* and an int.

Note
The use of this type outside very specific circumstances is foolish since there is no storage provided for the actual C string itself.

This type assumes use with type KEYWORD that is created by CMake and that table creates constant storage for C strings (and pointers to those C strings). Here we are only interested in the C strings themselves and only the pointers are duplicated within the hashtable. If the strings were not constant and fixed, this type would not work. Also note that normally a hashtable (i.e. unordered_map) using a const char* key would simply compare the 32 bit or 64 bit pointers themselves, rather than the C strings which they are known to point to in this context. I force the latter behavior by supplying both "hash" and "equality" overloads to the hashtable (unordered_map) template.

Author
Dick Hollenbeck

Definition at line 95 of file hashtables.h.