7 #ifndef SPACE_HASH_NATIVE_H
8 #define SPACE_HASH_NATIVE_H
10 #include <argos3/core/simulator/space/space_hash.h>
18 template <
class Element,
class Updater>
74 SBucketData* ElementList;
97 inline bool Empty()
const {
98 return (ElementList == NULL);
105 inline void Clear() {
107 SBucketData* psCur = ElementList;
108 SBucketData* psNext = psCur->Next;
112 if(psCur) psNext = psCur->Next;
125 inline void Add(Element& c_element,
129 if(Empty()) ElementList =
new SBucketData(c_element, n_i, n_j, n_k);
130 else ElementList =
new SBucketData(c_element, n_i, n_j, n_k, ElementList);
140 bool Exists(
const Element& c_element,
144 SBucketData* psCur = ElementList;
146 if(psCur->Elem == &c_element &&
149 psCur->K == n_k)
return true;
168 m_unCurrentStoreTimestamp(0) {}
175 delete[] m_psBuckets;
182 for(
size_t i = 0; i < CSpaceHash<Element,Updater>::GetSize(); ++i) {
183 m_psBuckets[i].Clear();
205 m_unCurrentStoreTimestamp++;
220 Element& c_element) {
224 SBucket& sBucket = m_psBuckets[nHash];
226 if(sBucket.StoreTimestamp == m_unCurrentStoreTimestamp) {
228 if(! sBucket.Exists(c_element, n_i, n_j, n_k)) {
229 sBucket.Add(c_element, n_i, n_j, n_k);
236 sBucket.StoreTimestamp = m_unCurrentStoreTimestamp;
238 sBucket.Add(c_element, n_i, n_j, n_k);
254 bool bNewElements =
false;
258 SBucket& sBucket = m_psBuckets[nHash];
263 if((sBucket.StoreTimestamp == m_unCurrentStoreTimestamp) &&
268 psCur = psCur->Next) {
270 if(n_i == psCur->I &&
275 t_elements.insert(psCur->Elem);
283 for(
size_t i = 0; i < CSpaceHash<Element,Updater>::GetSize(); ++i) {
284 if((m_psBuckets[i].StoreTimestamp == m_unCurrentStoreTimestamp) &&
285 !m_psBuckets[i].Empty()) {
286 c_os <<
"BUCKET " << i << std::endl;
289 psCur = psCur->Next) {
291 << psCur->Elem->GetId()
310 SBucket* m_psBuckets;
319 UInt64 m_unCurrentStoreTimestamp;