NEST main@caf0ae8
 
Loading...
Searching...
No Matches
sparse_node_array.h
Go to the documentation of this file.
1/*
2 * sparse_node_array.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef SPARSE_NODE_ARRAY_H
24#define SPARSE_NODE_ARRAY_H
25
26// C++ includes:
27#include <cassert>
28#include <map>
29
30// Includes from nestkernel:
31#include "exceptions.h"
32#include "nest_types.h"
33
34// Includes from libnestutil
35#include "block_vector.h"
36
37
38namespace nest
39{
40class Node;
41
86{
87public:
97 {
98 friend class SparseNodeArray;
99
100 public:
107 : node_( nullptr )
108 , node_id_( 0 )
109 {
110 }
111
116 NodeEntry( Node&, size_t );
117
118 Node* get_node() const;
119 size_t get_node_id() const;
120
121 private:
123 size_t node_id_;
124 };
125
128
131
139 size_t size() const;
140
142 void clear();
143
147 void add_local_node( Node& );
148
158 void set_max_node_id( size_t );
159
163 size_t get_max_node_id() const;
164
172 Node* get_node_by_node_id( size_t ) const;
173
179 Node* get_node_by_index( size_t ) const;
180
184 const_iterator begin() const;
185 const_iterator end() const;
186
187private:
188 bool is_consistent_() const;
189
194
195 double left_scale_;
197
205
210
217
222};
223
226{
227 return nodes_.begin();
228}
229
232{
233 return nodes_.end();
234}
235
236inline size_t
238{
239 return nodes_.size();
240}
241
242inline Node*
244{
245 assert( idx < nodes_.size() );
246 return nodes_[ idx ].node_;
247}
248
249inline size_t
254
255inline bool
257{
258 return nodes_.size() == 0 or global_max_node_id_ > 0;
259}
260
261inline Node*
263{
264 assert( node_ );
265 return node_;
266}
267
268inline size_t
270{
271 assert( node_id_ > 0 );
272 return node_id_;
273}
274
275} // namespace nest
276
277#endif /* SPARSE_NODE_ARRAY_H */
Container with a vector-of-vectors structure.
Definition block_vector.h:156
A BlockVector::iterator.
Definition block_vector.h:53
Base class for all NEST network objects.
Definition node.h:99
Entry representing individual node.
Definition sparse_node_array.h:97
NodeEntry()
Definition sparse_node_array.h:106
Node * get_node() const
return pointer to represented node
Definition sparse_node_array.h:262
Node * node_
Definition sparse_node_array.h:122
size_t get_node_id() const
return ID of represented node
Definition sparse_node_array.h:269
size_t node_id_
store node ID locally for faster searching
Definition sparse_node_array.h:123
Sparse representation of local nodes.
Definition sparse_node_array.h:86
size_t split_node_id_
Globally smallest node ID in right side of array.
Definition sparse_node_array.h:204
size_t local_max_node_id_
largest local node ID
Definition sparse_node_array.h:193
const_iterator end() const
Definition sparse_node_array.h:231
Node * get_node_by_node_id(size_t) const
Return pointer to node or nullptr if node is not local.
Definition sparse_node_array.cpp:130
size_t size() const
Return size of container.
Definition sparse_node_array.h:237
bool is_consistent_() const
Definition sparse_node_array.h:256
size_t get_max_node_id() const
Globally largest node ID.
Definition sparse_node_array.h:250
void set_max_node_id(size_t)
Set max node ID to maximum in network.
Definition sparse_node_array.cpp:118
bool left_side_has_proxies_
Proxy status of nodes on left side of array.
Definition sparse_node_array.h:221
void clear()
Clear the array.
Definition sparse_node_array.cpp:56
size_t split_idx_
Array index of first element in right side of array.
Definition sparse_node_array.h:209
BlockVector< SparseNodeArray::NodeEntry >::const_iterator const_iterator
Iterator inherited from BlockVector.
Definition sparse_node_array.h:127
SparseNodeArray()
Create empty sparse node array.
Definition sparse_node_array.cpp:40
double right_scale_
scale factor for right side of array
Definition sparse_node_array.h:196
double left_scale_
scale factor for left side of array
Definition sparse_node_array.h:195
bool have_split_
Mark whether split has happened during network construction.
Definition sparse_node_array.h:216
void add_local_node(Node &)
Add single local node.
Definition sparse_node_array.cpp:72
const_iterator begin() const
Constant iterators for safe iteration of SparseNodeArray.
Definition sparse_node_array.h:225
Node * get_node_by_index(size_t) const
Lookup node based on index into container.
Definition sparse_node_array.h:243
BlockVector< NodeEntry > nodes_
stores local node information
Definition sparse_node_array.h:190
size_t global_max_node_id_
globally largest node ID
Definition sparse_node_array.h:191
size_t local_min_node_id_
smallest local node ID
Definition sparse_node_array.h:192
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33