gwnavgeneration/generator/combinaisoncalculator.h Source File

combinaisoncalculator.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 
9 #pragma once
10 
12 
13 namespace Kaim
14 {
15 
16 class CombinaisonCalculator
17 {
18 public:
19  CombinaisonCalculator(KyUInt32 maxElementCountInCombinaison)
20  {
21  m_maxBitIndex = maxElementCountInCombinaison - 1;
22  m_maxBitMask = (1 << (m_maxBitIndex + 1)) - 1;
23  m_bitMask = 1; // we dont consider the
24  }
25 
26  bool IsFinished() const
27  {
28  return m_bitMask > m_maxBitMask;
29  }
30 
31  void Next()
32  {
33  ++m_bitMask;
34  }
35 
36  const KyArrayPOD<KyUInt32>& Compute()
37  {
38  m_currentCombinaison.Clear();
39 
40  for (KyUInt32 bitIndex = 0; bitIndex <= m_maxBitIndex; ++bitIndex)
41  {
42  KyUInt32 isBitAtIndex = (m_bitMask >> bitIndex) & 0x1;
43  if (isBitAtIndex)
44  m_currentCombinaison.PushBack(bitIndex);
45  }
46 
47  return m_currentCombinaison;
48  }
49 
50 public:
51  KyUInt32 m_maxBitIndex;
52  KyUInt32 m_maxBitMask;
53  KyUInt32 m_bitMask;
54  KyArrayPOD<KyUInt32> m_currentCombinaison;
55 };
56 
57 
58 } // namespace Kaim
59 
60 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17