gwnavruntime/containers/collection.h Source File

collection.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 #ifndef Navigation_Collection_H
9 #define Navigation_Collection_H
10 
15 
16 namespace Kaim
17 {
18 
19 template <typename T>
20 class CollectionIndexTracker_None;
21 
22 template <typename T>
23 class CollectionIndexTrackerPtr;
24 
25 template <class T, typename CollectionIndexTracker, int SID>
26 class CollectionImpl;
27 
28 static const KyUInt32 CollectionInvalidIndex = KyUInt32MAXVAL;
29 
31 template <class T, int SID = Stat_Default_Mem>
33 {
35 public:
36  // ---------------------------------- Public Member Functions ----------------------------------
37 
38  T& PushBack(const T& value);
39  T& PushBack();
40 
41  T& PushBackUnique(const T& value);
42 
43  void Clear();
44  void ClearAndReleaseMemory();
45  void Reserve(KyUInt32 size);
46 
47  KyUInt32 GetCount() const;
48  KyUInt32 GetCapacity() const;
49  bool IsEmpty() const;
50 
51  const T& operator[](KyUInt32 index) const;
52  T& operator[](KyUInt32 index) ;
53 
54  const T* GetDataPtr() const;
55  T* GetDataPtr();
56 
59  KyUInt32 RemoveAt(KyUInt32 index);
60 
61  KyUInt32 FindFirstOccurrence(const T& value, KyUInt32 startIndex = 0);
62  KyUInt32 RemoveFirstOccurrence(const T& value, KyUInt32 startIndex = 0);
63  bool DoesContain(const T& value) const;
64 
65 public: // internal
66  CollectionImpl<T, CollectionIndexTracker_None<T>, SID> m_collectionImpl;
67 };
68 
69 
77 template <class T, int SID = Stat_Default_Mem>
79 {
81 public:
82  // ---------------------------------- Public Member Functions ----------------------------------
83 
84  T& PushBack(const T& value);
85  T& PushBack();
86 
87  T& PushBackUnique(const T& value);
88 
89  void Clear();
90  void ClearAndReleaseMemory();
91  void Reserve(KyUInt32 size);
92 
93  KyUInt32 GetCount() const;
94  KyUInt32 GetCapacity() const;
95  bool IsEmpty() const;
96 
97  const T& operator[](KyUInt32 index) const;
98  T& operator[](KyUInt32 index) ;
99 
100  const T* GetDataPtr() const;
101  T* GetDataPtr();
102 
105  KyUInt32 RemoveAt(KyUInt32 index);
106 
107  KyUInt32 FindFirstOccurrence(const T& value, KyUInt32 startIndex = 0);
108  KyUInt32 RemoveFirstOccurrence(const T& value, KyUInt32 startIndex = 0);
109  bool DoesContain(const T& value) const;
110 
111  KyUInt32 Remove(const T& value);
112 
113 public: // internal
114  CollectionImpl<T, CollectionIndexTrackerPtr<T>, SID> m_collectionImpl;
115 };
116 
117 
118 } // namespace Kaim
119 
120 #include "gwnavruntime/containers/collection.inl"
121 
122 #endif
Collection is a class which is a "Collection" of elements (not sorted, not unique) ...
Definition: collection.h:32
TrackedCollection is a class which is a "Collection" of T=C* or T = Ptr< c="" /> (not sorted...
Definition: collection.h:87
KyUInt32 RemoveAt(KyUInt32 index)
Removes the element at specified index in the container.
Definition: collection.inl:204
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
KyUInt32 RemoveAt(KyUInt32 index)
Removes the element at specified index in the container.
Definition: collection.inl:162
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226