Version
menu_open
link
Wwise SDK 2023.1.3
AkHashTableTypes.h
Go to the documentation of this file.
1 /***********************************************************************
2  The content of this file includes source code for the sound engine
3  portion of the AUDIOKINETIC Wwise Technology and constitutes "Level
4  Two Source Code" as defined in the Source Code Addendum attached
5  with this file. Any use of the Level Two Source Code shall be
6  subject to the terms and conditions outlined in the Source Code
7  Addendum and the End User License Agreement for Wwise(R).
8 
9  Copyright (c) 2024 Audiokinetic Inc.
10  ***********************************************************************/
11 
12 #pragma once
13 
15 
16 // Basic types for an open-addressed hash array (or, otherwise, keyState-value array).
17 // Exposing enough data and structures to used for forward declarations of types.
18 // Helper and inlineable functions, especially for use by IAkPluginServiceHashTable,
19 // are available in AkHashTableFuncs.h
20 
21 // While the AkHashTableBase structures are exposed here, it is strongly recommended to use either the
22 // AkHashTable namespace functions to modify it, or the IAkPluginHashTable plug-in service, instead.
23 
24 namespace AK
25 {
26  // template instantiations available, in AkHashTable.cpp, are
27  // template<AkUInt32>
28  // template<AkUInt64>
29  template<typename KeyType>
30  struct AkHashTableBase {
32  : pKeys(nullptr)
33  , pbSlotOccupied(nullptr)
34  , pValues(nullptr)
36  , uNumUsedEntries(0)
38  {
39  }
40  KeyType* pKeys;
42  void* pValues;
43 
49 
50  static const AkUInt32 kDefaultMaxLoadFactor = 28; // divided by 32 = 87% load. Robin-hood-style storage ensures that most probe lengths should be low even at this ratio
51 
52  };
53 
54  // main class to use; trivially convertible to AkHashTableBase
55  // This allows for static disambiguation of hashtables for different value types; it's just syntactic sugar
56  template<typename KeyType, typename ValueType>
57  struct AkHashTable : public AkHashTableBase<KeyType>
58  {
59  ValueType* ValueData() { return (ValueType*)AkHashTableBase<KeyType>::pValues; }
60  const ValueType* ValueData() const { return (const ValueType*)AkHashTableBase<KeyType>::pValues; }
61 
62  ValueType& ValueAt(AkInt32 uSlot) { return ((ValueType*)AkHashTableBase<KeyType>::pValues)[uSlot]; }
63  const ValueType& ValueAt(AkInt32 uSlot) const { return ((ValueType*)AkHashTableBase<KeyType>::pValues)[uSlot]; }
64  };
65 
66 } // namespace AK
uint16_t AkUInt16
Unsigned 16-bit integer.
Audiokinetic namespace.
int32_t AkInt32
Signed 32-bit integer.
const ValueType & ValueAt(AkInt32 uSlot) const
ValueType * ValueData()
static const AkUInt32 kDefaultMaxLoadFactor
ValueType & ValueAt(AkInt32 uSlot)
uint32_t AkUInt32
Unsigned 32-bit integer.
const ValueType * ValueData() const

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise