gwnavruntime/containers/collection.h Source File

collection.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 #pragma once
9 
14 
15 namespace Kaim
16 {
17 
18 template <typename T>
19 class CollectionIndexTracker_None;
20 
21 template <typename T>
22 class CollectionIndexTrackerPtr;
23 
24 template <class T, typename CollectionIndexTracker, int SID>
25 class CollectionImpl;
26 
27 static const KyUInt32 CollectionInvalidIndex = KyUInt32MAXVAL;
28 
30 template <class T, int SID = Stat_Default_Mem>
32 {
34 public:
35  // ------------------------------ Functions -----------------------------
36 
37  T& PushBack(const T& value);
38  T& PushBack();
39 
40  T& PushBackUnique(const T& value);
41 
42  void Clear();
43  void ClearAndReleaseMemory();
44  void Reserve(KyUInt32 size);
45 
46  KyUInt32 GetCount() const;
47  KyUInt32 GetCapacity() const;
48  bool IsEmpty() const;
49 
50  const T& operator[](KyUInt32 index) const;
51  T& operator[](KyUInt32 index) ;
52 
53  const T* GetDataPtr() const;
54  T* GetDataPtr();
55 
58  KyUInt32 RemoveAt(KyUInt32 index);
59 
60  KyUInt32 FindFirstOccurrence(const T& value, KyUInt32 startIndex = 0);
61  KyUInt32 RemoveFirstOccurrence(const T& value, KyUInt32 startIndex = 0);
62  bool DoesContain(const T& value) const;
63 
64 public: // internal
65  CollectionImpl<T, CollectionIndexTracker_None<T>, SID> m_collectionImpl;
66 };
67 
68 
76 template <class T, int SID = Stat_Default_Mem>
78 {
80 public:
81  // ------------------------------ Functions -----------------------------
82 
83  T& PushBack(const T& value);
84  T& PushBack();
85 
86  T& PushBackUnique(const T& value);
87 
88  void Clear();
89  void ClearAndReleaseMemory();
90  void Reserve(KyUInt32 size);
91 
92  KyUInt32 GetCount() const;
93  KyUInt32 GetCapacity() const;
94  bool IsEmpty() const;
95 
96  const T& operator[](KyUInt32 index) const;
97  T& operator[](KyUInt32 index) ;
98 
99  const T* GetDataPtr() const;
100  T* GetDataPtr();
101 
104  KyUInt32 RemoveAt(KyUInt32 index);
105 
106  KyUInt32 FindFirstOccurrence(const T& value, KyUInt32 startIndex = 0);
107  KyUInt32 RemoveFirstOccurrence(const T& value, KyUInt32 startIndex = 0);
108  bool DoesContain(const T& value) const;
109 
110  KyUInt32 Remove(const T& value);
111 
112 public: // internal
113  CollectionImpl<T, CollectionIndexTrackerPtr<T>, SID> m_collectionImpl;
114 };
115 
116 
117 } // namespace Kaim
118 
120 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
Collection is a class which is a "Collection" of elements (not sorted, not unique) ...
Definition: collection.h:31
TrackedCollection is a class which is a "Collection" of T=C* or T = Ptr< c="" /> (not sorted...
Definition: collection.h:77
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
KyUInt32 RemoveAt(KyUInt32 index)
Removes the element at specified index in the container.
Definition: collection.inl:204
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
KyUInt32 RemoveAt(KyUInt32 index)
Removes the element at specified index in the container.
Definition: collection.inl:162
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68