gwnavgeneration/generator/combinaisoncalculator.h Source File

combinaisoncalculator.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 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 // primary contact: JODA - secondary contact: GUAL
10 #ifndef GwNavGen_CombinaisonCalculator_H
11 #define GwNavGen_CombinaisonCalculator_H
12 
14 
15 namespace Kaim
16 {
17 
18 class CombinaisonCalculator
19 {
20 public:
21  CombinaisonCalculator(KyUInt32 maxElementCountInCombinaison)
22  {
23  m_maxBitIndex = maxElementCountInCombinaison - 1;
24  m_maxBitMask = (1 << (m_maxBitIndex + 1)) - 1;
25  m_bitMask = 1; // we dont consider the
26  }
27 
28  bool IsFinished() const
29  {
30  return m_bitMask > m_maxBitMask;
31  }
32 
33  void Next()
34  {
35  ++m_bitMask;
36  }
37 
38  const KyArrayPOD<KyUInt32>& Compute()
39  {
40  m_currentCombinaison.Clear();
41 
42  for (KyUInt32 bitIndex = 0; bitIndex <= m_maxBitIndex; ++bitIndex)
43  {
44  KyUInt32 isBitAtIndex = (m_bitMask >> bitIndex) & 0x1;
45  if (isBitAtIndex)
46  m_currentCombinaison.PushBack(bitIndex);
47  }
48 
49  return m_currentCombinaison;
50  }
51 
52 public:
53  KyUInt32 m_maxBitIndex;
54  KyUInt32 m_maxBitMask;
55  KyUInt32 m_bitMask;
56  KyArrayPOD<KyUInt32> m_currentCombinaison;
57 };
58 
59 
60 } // namespace Kaim
61 
62 
63 #endif
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36