Skip to content

Commit c4290bf

Browse files
author
nitrocaster
committed
Merge CDataStorageSingleLinkedList list into CDataStorageDoubleLinkedList.
1 parent c40622a commit c4290bf

11 files changed

+52
-288
lines changed

src/xrAICore/Navigation/data_storage_bucket_list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct CDataStorageBucketList {
3737
_data_storage,
3838
BucketList<_vertex>::_vertex
3939
> inherited;
40-
typedef typename inherited::inherited_base inherited_base;
40+
typedef typename inherited::inherited inherited_base;
4141
typedef typename inherited::CGraphVertex CGraphVertex;
4242
typedef typename CGraphVertex::_dist_type _dist_type;
4343
typedef typename CGraphVertex::_index_type _index_type;

src/xrAICore/Navigation/data_storage_constructor.h

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,14 @@ template <
1818
typename _manager,
1919
typename _builder,
2020
typename _allocator,
21-
template <typename _T> class _vertex = CEmptyClassTemplate,
22-
template <
23-
typename _1,
24-
typename _2
25-
>
26-
class _builder_allocator_constructor = CBuilderAllocatorConstructor,
27-
template <
28-
typename _1,
29-
typename _2,
30-
typename _3,
31-
template <
32-
typename _1,
33-
typename _2
34-
>
35-
class _4
36-
>
37-
class _manager_builder_allocator_constructor = CManagerBuilderAllocatorConstructor
21+
template <typename _T> class _vertex = CEmptyClassTemplate
3822
>
3923
struct CDataStorageConstructor :
4024
public _algorithm::template CDataStorage<
41-
_manager_builder_allocator_constructor<
42-
_manager,
43-
_builder,
44-
_allocator,
45-
_builder_allocator_constructor
46-
>,
47-
_vertex
48-
>
25+
CManagerBuilderAllocatorConstructor<_manager, _builder, _allocator>, _vertex>
4926
{
5027
typedef typename _algorithm::template CDataStorage<
51-
_manager_builder_allocator_constructor<
52-
_manager,
53-
_builder,
54-
_allocator,
55-
_builder_allocator_constructor
56-
>,
57-
_vertex
58-
> inherited;
28+
CManagerBuilderAllocatorConstructor<_manager, _builder, _allocator>, _vertex> inherited;
5929

6030
typedef typename inherited::CGraphVertex CGraphVertex;
6131
typedef typename CGraphVertex::_index_type _index_type;

src/xrAICore/Navigation/data_storage_double_linked_list.h

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,47 @@
88

99
#pragma once
1010

11-
#include "xrAICore/Navigation/data_storage_single_linked_list.h"
12-
1311
template <bool sorted = false>
14-
struct CDataStorageDoubleLinkedList {
15-
12+
struct CDataStorageDoubleLinkedList
13+
{
1614
template <template <typename _T> class T1>
17-
struct DoubleLinkedList {
15+
struct DoubleLinkedList
16+
{
1817
template<typename T2>
19-
struct _vertex : public T1<T2> {
20-
T2 *_prev;
21-
22-
IC T2 *&prev()
23-
{
24-
return (_prev);
25-
}
18+
struct _vertex : public T1<T2>
19+
{
20+
T2 *_next;
21+
T2 *_prev;
22+
T2 *&next() { return _next; }
23+
T2 *&prev() { return _prev; }
2624
};
2725
};
2826

2927
template <
3028
typename _data_storage,
3129
template <typename _T> class _vertex = CEmptyClassTemplate
3230
>
33-
class CDataStorage : public CDataStorageSingleLinkedList<sorted>::CDataStorage<_data_storage,DoubleLinkedList<_vertex>::_vertex> {
31+
class CDataStorage : public _data_storage::template CDataStorage<DoubleLinkedList<_vertex>::_vertex>
32+
{
3433
public:
35-
typedef typename CDataStorageSingleLinkedList<sorted>::CDataStorage<
36-
_data_storage,
37-
DoubleLinkedList<_vertex>::_vertex
38-
> inherited;
39-
typedef typename inherited::inherited inherited_base;
34+
typedef typename _data_storage::template CDataStorage<DoubleLinkedList<_vertex>::_vertex> inherited;
4035
typedef typename inherited::CGraphVertex CGraphVertex;
4136
typedef typename CGraphVertex::_dist_type _dist_type;
4237
typedef typename CGraphVertex::_index_type _index_type;
4338

4439
protected:
45-
_dist_type m_switch_factor;
40+
_dist_type m_max_distance;
41+
CGraphVertex m_list_data[2];
42+
CGraphVertex *m_list_head;
43+
CGraphVertex *m_list_tail;
44+
_dist_type m_switch_factor;
4645

4746
public:
4847
IC CDataStorage (const u32 vertex_count, const _dist_type _max_distance = _dist_type(u32(-1)));
4948
virtual ~CDataStorage ();
5049
IC void init ();
50+
IC bool is_opened_empty () const;
51+
IC void add_best_closed ();
5152
IC void set_switch_factor (const _dist_type _switch_factor);
5253
IC void add_opened (CGraphVertex &vertex);
5354
IC void decrease_opened (CGraphVertex &vertex, const _dist_type value);

src/xrAICore/Navigation/data_storage_double_linked_list_inline.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ TEMPLATE_SPECIALIZATION
2121
IC CDoubleLinkedList::CDataStorage (const u32 vertex_count, const _dist_type _max_distance = _dist_type(u32(-1))) :
2222
inherited (vertex_count)
2323
{
24+
m_max_distance = _max_distance;
2425
m_switch_factor = _dist_type(1);
2526
}
2627

@@ -33,13 +34,24 @@ TEMPLATE_SPECIALIZATION
3334
IC void CDoubleLinkedList::init ()
3435
{
3536
inherited::init ();
37+
ZeroMemory (m_list_data,2*sizeof(CGraphVertex));
38+
m_list_head = m_list_data;
39+
m_list_tail = m_list_data + 1;
40+
m_list_head->next() = m_list_tail;
41+
m_list_tail->f() = m_max_distance;
3642
m_list_tail->prev() = m_list_head;
3743
}
3844

45+
TEMPLATE_SPECIALIZATION
46+
IC bool CDoubleLinkedList::is_opened_empty () const
47+
{
48+
return (m_list_head->next() == m_list_tail);
49+
}
50+
3951
TEMPLATE_SPECIALIZATION
4052
IC void CDoubleLinkedList::add_opened (CGraphVertex &vertex)
4153
{
42-
inherited_base::add_opened (vertex);
54+
inherited::add_opened (vertex);
4355
if (!sorted) {
4456
m_list_head->next()->prev() = &vertex;
4557
vertex.next() = m_list_head->next();
@@ -106,7 +118,14 @@ IC void CDoubleLinkedList::remove_best_opened ()
106118
{
107119
VERIFY (!is_opened_empty());
108120
m_list_head->next()->next()->prev() = m_list_head;
109-
inherited::remove_best_opened();
121+
m_list_head->next() = m_list_head->next()->next();
122+
}
123+
124+
TEMPLATE_SPECIALIZATION
125+
IC void CDoubleLinkedList::add_best_closed ()
126+
{
127+
VERIFY (!is_opened_empty());
128+
inherited::add_closed (*m_list_head->next());
110129
}
111130

112131
TEMPLATE_SPECIALIZATION

src/xrAICore/Navigation/data_storage_single_linked_list.h

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/xrAICore/Navigation/data_storage_single_linked_list_inline.h

Lines changed: 0 additions & 136 deletions
This file was deleted.

src/xrAICore/Navigation/dijkstra.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ template <
5252
_vertex_manager,
5353
_data_storage_base,
5454
_vertex_allocator,
55-
_Vertex,
56-
CBuilderAllocatorConstructor,
57-
CManagerBuilderAllocatorConstructor
55+
_Vertex
5856
> CDataStorage;
5957

6058
protected:

0 commit comments

Comments
 (0)