~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/yapf/nodelist.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: nodelist.hpp 10392 2007-06-29 23:45:13Z KUDr $ */
 
1
/* $Id: nodelist.hpp 15718 2009-03-15 00:32:18Z rubidium $ */
2
2
 
3
 
/** @file nodelist.hpp */
 
3
/** @file nodelist.hpp List of nodes used for the A-star pathfinder. */
4
4
 
5
5
#ifndef  NODELIST_HPP
6
6
#define  NODELIST_HPP
46
46
        {
47
47
                m_new_node = NULL;
48
48
        }
 
49
 
49
50
        /** destructor */
50
51
        ~CNodeList_HashTableT()
51
52
        {
52
53
        }
 
54
 
53
55
        /** return number of open nodes */
54
 
        FORCEINLINE int OpenCount() {return m_open.Count();}
 
56
        FORCEINLINE int OpenCount()
 
57
        {
 
58
                return m_open.Count();
 
59
        }
 
60
 
55
61
        /** return number of closed nodes */
56
 
        FORCEINLINE int ClosedCount() {return m_closed.Count();}
 
62
        FORCEINLINE int ClosedCount()
 
63
        {
 
64
                return m_closed.Count();
 
65
        }
 
66
 
57
67
        /** allocate new data item from m_arr */
58
 
        FORCEINLINE Titem_* CreateNewNode()
 
68
        FORCEINLINE Titem_ *CreateNewNode()
59
69
        {
60
70
                if (m_new_node == NULL) m_new_node = &m_arr.Add();
61
71
                return m_new_node;
62
72
        }
 
73
 
63
74
        /** notify the nodelist, that we don't want to discard the given node */
64
75
        FORCEINLINE void FoundBestNode(Titem_& item)
65
76
        {
66
 
                // for now it is enough to invalidate m_new_node if it is our given node
67
 
                if (&item == m_new_node)
 
77
                /* for now it is enough to invalidate m_new_node if it is our given node */
 
78
                if (&item == m_new_node) {
68
79
                        m_new_node = NULL;
69
 
                // TODO: do we need to store best nodes found in some extra list/array? Probably not now.
 
80
                }
 
81
                /* TODO: do we need to store best nodes found in some extra list/array? Probably not now. */
70
82
        }
 
83
 
71
84
        /** insert given item as open node (into m_open and m_open_queue) */
72
85
        FORCEINLINE void InsertOpenNode(Titem_& item)
73
86
        {
74
87
                assert(m_closed.Find(item.GetKey()) == NULL);
75
88
                m_open.Push(item);
76
 
                // TODO: check if m_open_queue is not full
 
89
                /* TODO: check if m_open_queue is not full */
77
90
                assert(!m_open_queue.IsFull());
78
91
                m_open_queue.Push(item);
79
 
                if (&item == m_new_node)
 
92
                if (&item == m_new_node) {
80
93
                        m_new_node = NULL;
 
94
                }
81
95
        }
 
96
 
82
97
        /** return the best open node */
83
 
        FORCEINLINE Titem_* GetBestOpenNode()
 
98
        FORCEINLINE Titem_ *GetBestOpenNode()
84
99
        {
85
100
                if (!m_open_queue.IsEmpty()) {
86
101
                        Titem_& item = m_open_queue.GetHead();
88
103
                }
89
104
                return NULL;
90
105
        }
 
106
 
91
107
        /** remove and return the best open node */
92
 
        FORCEINLINE Titem_* PopBestOpenNode()
 
108
        FORCEINLINE Titem_ *PopBestOpenNode()
93
109
        {
94
110
                if (!m_open_queue.IsEmpty()) {
95
111
                        Titem_& item = m_open_queue.PopHead();
98
114
                }
99
115
                return NULL;
100
116
        }
 
117
 
101
118
        /** return the open node specified by a key or NULL if not found */
102
 
        FORCEINLINE Titem_* FindOpenNode(const Key& key)
 
119
        FORCEINLINE Titem_ *FindOpenNode(const Key& key)
103
120
        {
104
 
                Titem_* item = m_open.Find(key);
 
121
                Titem_ *item = m_open.Find(key);
105
122
                return item;
106
123
        }
 
124
 
107
125
        /** remove and return the open node specified by a key */
108
126
        FORCEINLINE Titem_& PopOpenNode(const Key& key)
109
127
        {
112
130
                m_open_queue.RemoveByIdx(idxPop);
113
131
                return item;
114
132
        }
 
133
 
115
134
        /** close node */
116
135
        FORCEINLINE void InsertClosedNode(Titem_& item)
117
136
        {
118
137
                assert(m_open.Find(item.GetKey()) == NULL);
119
138
                m_closed.Push(item);
120
139
        }
 
140
 
121
141
        /** return the closed node specified by a key or NULL if not found */
122
 
        FORCEINLINE Titem_* FindClosedNode(const Key& key)
 
142
        FORCEINLINE Titem_ *FindClosedNode(const Key& key)
123
143
        {
124
 
                Titem_* item = m_closed.Find(key);
 
144
                Titem_ *item = m_closed.Find(key);
125
145
                return item;
126
146
        }
127
147