forked from JNighthawk/bdotools-conversation-solver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.h
53 lines (43 loc) · 1.38 KB
/
Utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#if !defined(UTILS_H)
#define UTILS_H
#include <string>
#include <vector>
std::string GetLowerString(const std::string& sString);
void LowerString(std::string& sString);
// Block allocator using static memory
template <typename T>
class CMemory
{
public:
static std::vector<T> s_vBlocks;
static int s_nBlockIndex;
static void Init(int nNumBlocks)
{
s_vBlocks.resize(nNumBlocks);
s_nBlockIndex = 0;
}
static T* Alloc(int nNum)
{
T* pReturn = &s_vBlocks[s_nBlockIndex];
s_nBlockIndex += nNum;
if (s_nBlockIndex > s_vBlocks.size())
{
return nullptr;
}
return pReturn;
}
};
template <typename T>
std::vector<T> CMemory<T>::s_vBlocks;
template <typename T>
int CMemory<T>::s_nBlockIndex = 0;
template <typename T>
inline void GeneratePermutations(std::vector<std::vector<T>>& vResults, const std::vector<T>& vStartingCombination);
template <typename T>
inline std::vector<std::vector<T>> GenerateCombinationsAndPermutations(const std::vector<T>& vObjects, int nResultSlots);
template <typename T>
inline void GeneratePermutationsStaticMemory(std::vector<T*>& vResults, T* pStartingCombination, int nResultSlots);
template <typename T, bool t_bPermutations>
inline std::vector<T*> GenerateCombinationsAndPermutationsStaticMemory(const std::vector<T>& vObjects, int nResultSlots);
#include "Utils.inl"
#endif // !defined(UTILS_H)