SST  14.1.0
StructuralSimulationToolkit
sparseVectorMap.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2024 NTESS. Under the terms
4 // of Contract DE-NA0003525 with NTESS, the U.S.
5 // Government retains certain rights in this software.
6 //
7 // Copyright (c) 2009-2024, NTESS
8 // All rights reserved.
9 //
10 // This file is part of the SST software package. For license
11 // information, see the LICENSE file in the top level directory of the
12 // distribution.
13 
14 #ifndef SST_CORE_SPARSEVECTORMAP_H
15 #define SST_CORE_SPARSEVECTORMAP_H
16 
17 #include "sst/core/serialization/serializable.h"
18 #include "sst/core/sst_types.h"
19 
20 #include <algorithm>
21 #include <vector>
22 
23 namespace SST {
24 
25 /**
26  Class that stores data in a vector, but can access the data similar
27  to a map. The data structure is O(log n) on reads, but is O(n) to
28  insert. The primary use case is when data is inserted in order, but
29  accessed randomly. You can also create the SparseVectorMap with a
30  vector already loaded with the data. If the data is not already
31  sorted, it will call std::sort on the data, which likely has an
32  average complexity of O(n log n). This data structure should not
33  be used for large lists where inserts do not happen in sorted order.
34 
35  NOTE: Since the data is stored in the vector, reference returned
36  from the various accessor functions will not be valid longterm. If
37  an insert causes the vector to be resized, all references returned
38  before that reallocation may (likely will) be invalid. References
39  are only guaranteed to be valid until the next write to the data
40  structure.
41  */
42 template <typename keyT, typename classT = keyT>
44 {
45 private:
46  friend class SST::Core::Serialization::serialize<SparseVectorMap<keyT, classT>>;
47 
48  /**
49  Finds the insertion point for new data
50 
51  @param id ID of the data that needs to be inserted.
52 
53  @return Index where new data should be inserted. If key is
54  already in the map, it will return -1.
55  */
56  std::vector<classT> data;
57  int binary_search_insert(keyT id) const
58  {
59  // For insert, we've found the right place when id < n && id >
60  // n-1. We then insert at n.
61 
62  int size = data.size();
63 
64  // Check to see if it goes top or bottom
65  if ( size == 0 ) return 0;
66  if ( id > data[size - 1].key() ) return size;
67  if ( id < data[0].key() ) return 0;
68 
69  int bottom = 0;
70  int top = size - 1;
71  int middle;
72 
73  while ( bottom <= top ) {
74  middle = bottom + (top - bottom) / 2;
75  if ( id == data[middle].key() ) return -1; // Already in map
76  if ( id < data[middle].key() ) {
77  // May be the right place, need to see if id is greater
78  // than the one before the current middle. If so, then we
79  // have the right place.
80  if ( id > data[middle - 1].key() )
81  return middle;
82  else {
83  top = middle - 1;
84  }
85  }
86  else {
87  bottom = middle + 1;
88  }
89  }
90  /* Shouldn't be reached */
91  return -1;
92  }
93 
94  /**
95  Finds the index where the data associated with the given key is
96  found in the vector
97 
98  @param id ID of the data that needs to be found.
99 
100  @return Index where data for the provided ID is found. It
101  returns -1 if the key is not found in the data vector.
102  */
103  int binary_search_find(keyT id) const
104  {
105  int bottom = 0;
106  int top = data.size() - 1;
107  int middle;
108 
109  if ( data.size() == 0 ) return -1;
110  while ( bottom <= top ) {
111  middle = bottom + (top - bottom) / 2;
112  if ( id == data[middle].key() )
113  return middle;
114  else if ( id < data[middle].key() )
115  top = middle - 1;
116  else
117  bottom = middle + 1;
118  }
119  return -1;
120  }
121 
122  friend class ConfigGraph;
123 
124 public:
125  /**
126  Default constructor for SparseVectorMap
127  */
129 
130  /**
131  Constructor that allows you to pass an already filled in array
132  with data. The data in the passed in vector will be swapped
133  into the data vector of the sparsevectormap and the passed in
134  vector will be empty.
135 
136  @param new_data Vector of data to swap into the sparsevectormap
137  data
138 
139  @param sorted Specifies whether the vector is already sorted in
140  ascending order. if not, it will be sorted after swapping the
141  data in.
142  */
143  SparseVectorMap(std::vector<classT>& new_data, bool sorted = false)
144  {
145  data.swap(new_data);
146  if ( !sorted ) {
147  std::sort(data.begin(), data.end, [](const classT& lhs, const classT& rhs) -> bool {
148  return lhs.key() < rhs.key();
149  });
150  }
151  }
152 
153  typedef typename std::vector<classT>::iterator iterator;
154  typedef typename std::vector<classT>::const_iterator const_iterator;
155 
156  /**
157  Insert new value into SparseVectorMap. The inserted class must
158  have a key() function with return type keyT.
159 
160  @param val value to add to SparseVectorMap
161 
162  @return reference to the inserted item, or to the existing item
163  if it was already present in the map.
164 
165  */
166  classT& insert(const classT& val)
167  {
168  int index = binary_search_insert(val.key());
169  if ( index == -1 ) return data[binary_search_find(val.key())]; // already in the map
170  iterator it = data.begin();
171  it += index;
172  data.insert(it, val);
173  return data[index];
174  }
175 
176  /**
177  Returns the begin iterator to the underlying vector.
178 
179  @return begin iterator to data vector
180  */
181  iterator begin() { return data.begin(); }
182 
183  /**
184  Returns the end iterator to the underlying vector.
185 
186  @return end iterator to data vector
187  */
188  iterator end() { return data.end(); }
189 
190  /**
191  Returns the const begin iterator to the underlying vector.
192 
193  @return const begin iterator to data vector
194  */
195  const_iterator begin() const { return data.begin(); }
196 
197  /**
198  Returns the const end iterator to the underlying vector.
199 
200  @return const end iterator to data vector
201  */
202  const_iterator end() const { return data.end(); }
203 
204  /**
205  Checks if the provided id is found in the SparseVectorMap
206 
207  @param id id to check for
208 
209  @return true if id is found, false otherwise
210  */
211  bool contains(keyT id) const
212  {
213  if ( binary_search_find(id) == -1 ) return false;
214  return true;
215  }
216 
217  /**
218  Operator returns a reference to data with the specified id.
219  Value can be modified. This will only return references to
220  existing values, you must use insert() for new values.
221 
222  @param id id of the value to return (value returned by key())
223 
224  @return reference to the requested item.
225 
226  */
227  classT& operator[](keyT id)
228  {
229  int index = binary_search_find(id);
230  if ( index == -1 ) {
231  // Need to error out
232  }
233  return data[index];
234  }
235 
236  /**
237  Operator returns a const reference to data with the specified
238  id. Value cannot be modified. This will only return
239  references to existing values, you must use insert() for new
240  values.
241 
242  @param id id of the value to return (value returned by key())
243 
244  @return const reference to the requested item.
245 
246  */
247  const classT& operator[](keyT id) const
248  {
249  int index = binary_search_find(id);
250  if ( index == -1 ) {
251  // Need to error out
252  }
253  return data[index];
254  }
255 
256  /**
257  Clears the contents of the SparseVectorMap
258  */
259  void clear() { data.clear(); }
260 
261  /**
262  Returns the number of items in the SparseVectorMap
263 
264  @return number of items
265  */
266  size_t size() { return data.size(); }
267 };
268 
269 
270 /**
271  Exception that is thrown by SparseVectorMap::filter() if the
272  filtering object returns an object that returns a different value
273  from the key() function than what was passed into the filter.
274  */
275 class bad_filtered_key_error : public std::runtime_error
276 {
277 public:
278  bad_filtered_key_error(const std::string& what_arg) : runtime_error(what_arg) {}
279 };
280 
281 
282 /**
283  Class that stores data in a vector, but can access the data similar
284  to a map. The data structure is O(log n) on reads, but is O(n) to
285  insert. The primary use case is when data is inserted in order, but
286  accessed randomly. You can also create the SparseVectorMap with a
287  vector already loaded with the data. If the data is not already
288  sorted, it will call std::sort on the data, which likely has an
289  average complexity of O(n log n). This data structure should not
290  be used for large lists where inserts do not happen in sorted order.
291 
292  NOTE: Since the data is stored in the vector, reference returned
293  from the various accessor functions will not be valid longterm. If
294  an insert causes the vector to be resized, all references returned
295  before that reallocation may (likely will) be invalid. References
296  are only guaranteed to be valid until the next write to the data
297  structure.
298  */
299 template <typename keyT, typename classT>
300 class SparseVectorMap<keyT, classT*>
301 {
302 private:
303  friend class SST::Core::Serialization::serialize<SparseVectorMap<keyT, classT*>>;
304 
305  /**
306  Finds the insertion point for new data
307 
308  @param id ID of the data that needs to be inserted.
309 
310  @return Index where new data should be inserted. If key is
311  already in the map, it will return -1.
312  */
313  std::vector<classT*> data;
314  int binary_search_insert(keyT id) const
315  {
316  // For insert, we've found the right place when id < n && id >
317  // n-1. We then insert at n.
318 
319  int size = data.size();
320 
321  // Check to see if it goes top or bottom
322  if ( size == 0 ) return 0;
323  if ( id > data[size - 1]->key() ) return size;
324  if ( id < data[0]->key() ) return 0;
325 
326  int bottom = 0;
327  int top = size - 1;
328  int middle;
329 
330  while ( bottom <= top ) {
331  middle = bottom + (top - bottom) / 2;
332  if ( id == data[middle]->key() ) return -1; // Already in map
333  if ( id < data[middle]->key() ) {
334  // May be the right place, need to see if id is greater
335  // than the one before the current middle. If so, then we
336  // have the right place.
337  if ( id > data[middle - 1]->key() )
338  return middle;
339  else {
340  top = middle - 1;
341  }
342  }
343  else {
344  bottom = middle + 1;
345  }
346  }
347  /* Shouldn't be reached */
348  return -1;
349  }
350 
351  /**
352  Finds the index where the data associated with the given key is
353  found in the vector
354 
355  @param id ID of the data that needs to be found.
356 
357  @return Index where data for the provided ID is found. It
358  returns -1 if the key is not found in the data vector.
359  */
360  int binary_search_find(keyT id) const
361  {
362  int bottom = 0;
363  int top = data.size() - 1;
364  int middle;
365 
366  if ( data.size() == 0 ) return -1;
367  while ( bottom <= top ) {
368  middle = bottom + (top - bottom) / 2;
369  if ( id == data[middle]->key() )
370  return middle;
371  else if ( id < data[middle]->key() )
372  top = middle - 1;
373  else
374  bottom = middle + 1;
375  }
376  return -1;
377  }
378 
379  friend class ConfigGraph;
380 
381 public:
382  /**
383  Default constructor for SparseVectorMap
384  */
386 
387  /**
388  Constructor that allows you to pass an already filled in array
389  with data. The data in the passed in vector will be swapped
390  into the data vector of the sparsevectormap and the passed in
391  vector will be empty.
392 
393  @param new_data Vector of data to swap into the sparsevectormap
394  data
395 
396  @param sorted Specifies whether the vector is already sorted in
397  ascending order. if not, it will be sorted after swapping the
398  data in.
399  */
400  SparseVectorMap(std::vector<classT*>& new_data, bool sorted = false)
401  {
402  data.swap(new_data);
403  if ( !sorted ) {
404  std::sort(data.begin(), data.end, [](const classT* lhs, const classT* rhs) -> bool {
405  return lhs->key() < rhs->key();
406  });
407  }
408  }
409 
410  typedef typename std::vector<classT*>::iterator iterator;
411  typedef typename std::vector<classT*>::const_iterator const_iterator;
412 
413  /**
414  Insert new value into SparseVectorMap. The inserted class must
415  have a key() function with return type keyT.
416 
417  @param val value to add to SparseVectorMap
418 
419  @return reference to the inserted item, or to the existing item
420  if it was already present in the map.
421 
422  */
423  classT* insert(classT* val)
424  {
425  int index = binary_search_insert(val->key());
426  if ( index == -1 ) return data[binary_search_find(val->key())]; // already in the map
427  iterator it = data.begin();
428  it += index;
429  data.insert(it, val);
430  return data[index];
431  }
432 
433  /**
434  Returns the begin iterator to the underlying vector.
435 
436  @return begin iterator to data vector
437  */
438  iterator begin() { return data.begin(); }
439 
440  /**
441  Returns the end iterator to the underlying vector.
442 
443  @return end iterator to data vector
444  */
445  iterator end() { return data.end(); }
446 
447  /**
448  Returns the const begin iterator to the underlying vector.
449 
450  @return const begin iterator to data vector
451  */
452  const_iterator begin() const { return data.begin(); }
453 
454  /**
455  Returns the const end iterator to the underlying vector.
456 
457  @return const end iterator to data vector
458  */
459  const_iterator end() const { return data.end(); }
460 
461  /**
462  Checks if the provided id is found in the SparseVectorMap
463 
464  @param id id to check for
465 
466  @return true if id is found, false otherwise
467  */
468  bool contains(keyT id) const
469  {
470  if ( binary_search_find(id) == -1 ) return false;
471  return true;
472  }
473 
474  /**
475  Operator returns a reference to data with the specified id.
476  Value can be modified. This will only return references to
477  existing values, you must use insert() for new values.
478 
479  @param id id of the value to return (value returned by key())
480 
481  @return reference to the requested item.
482 
483  */
484  classT* operator[](keyT id)
485  {
486  int index = binary_search_find(id);
487  if ( index == -1 ) {
488  // Need to error out
489  }
490  return data[index];
491  }
492 
493  /**
494  Operator returns a const reference to data with the specified
495  id. Value cannot be modified. This will only return
496  references to existing values, you must use insert() for new
497  values.
498 
499  @param id id of the value to return (value returned by key())
500 
501  @return const reference to the requested item.
502 
503  */
504  const classT* operator[](keyT id) const
505  {
506  int index = binary_search_find(id);
507  if ( index == -1 ) {
508  // Need to error out
509  }
510  return data[index];
511  }
512 
513  /**
514  Clears the contents of the SparseVectorMap
515  */
516  void clear() { data.clear(); }
517 
518  /**
519  Returns the number of items in the SparseVectorMap
520 
521  @return number of items
522  */
523  size_t size() { return data.size(); }
524 
525 
526  /**
527  Function to filter the contents of the SparseVectorMap. Takes
528  an object with an overloaded operator() function that takes as
529  argument the current item. The funtion returns the object that
530  should take the place of this object (value returned by key()
531  function must be same for both objects), or returns nullptr if
532  the object should be deleted. When an item is deleted, the
533  size of the map reduces by 1.
534 
535  @param filt Filter object to use for filtering contents of map
536 
537  @exception bad_filtered_key_error filter returned an object that
538  didn't return the same value on a call to key() as the original
539  object in the map.
540  */
541  template <typename filterT>
542  void filter(filterT& filt)
543  {
544  int write_ptr = 0;
545  for ( size_t i = 0; i < data.size(); ++i ) {
546  auto key = data[i]->key();
547  data[write_ptr] = filt(data[i]);
548  if ( data[write_ptr] != nullptr ) {
549  // Make sure the keys match
550  if ( UNLIKELY(data[write_ptr]->key() != key) ) {
551  // No recovering from this, just need to error out
553  "ERROR: Filter object passed to SparseVectorMap::filter returned an object that had a "
554  "different value of key() than what was passed into the filter. The filter object must return "
555  "either an object with the same value of key(), or nullptr if the object should be removed.");
556  }
557  write_ptr++;
558  }
559  }
560  // Need to shorten vector if items were removed. The
561  // write_ptr will be at the index with the first nullptr from
562  // the filter, and tells us where to cut things off. So,
563  // simply call resize() on the vector with write_ptr as the
564  // new size.
565  data.resize(write_ptr);
566  data.shrink_to_fit();
567  }
568 };
569 
570 /**
571  Templated version of SparseVectorMap where the data and key are the
572  same (actually more like a set than a map in this case). The type
573  must implement the less than operator. This is primarily intended
574  for use with native types.
575  */
576 template <typename keyT>
577 class SparseVectorMap<keyT, keyT>
578 {
579 private:
580  friend class SST::Core::Serialization::serialize<SparseVectorMap<keyT, keyT>>;
581 
582  /**
583  Finds the insertion point for new data
584 
585  @param id ID of the data that needs to be inserted.
586 
587  @return Index where new data should be inserted. If key is
588  already in the map, it will return -1.
589  */
590  std::vector<keyT> data;
591  int binary_search_insert(keyT id) const
592  {
593  // For insert, we've found the right place when id < n && id >
594  // n-1. We then insert at n.
595 
596  int size = data.size();
597 
598  // Check to see if it goes top or bottom
599  if ( size == 0 ) return 0;
600  if ( id < data[0] ) return 0;
601  if ( id > data[size - 1] ) return size;
602 
603  int bottom = 0;
604  int top = size - 1;
605  int middle;
606 
607  while ( bottom <= top ) {
608  middle = bottom + (top - bottom) / 2;
609  if ( id == data[middle] ) return -1; // Already in map
610  if ( id < data[middle] ) {
611  // May be the right place, need to see if id is greater
612  // than the one before the current middle. If so, then we
613  // have the right place.
614  if ( id > data[middle - 1] )
615  return middle;
616  else {
617  top = middle - 1;
618  }
619  }
620  else {
621  bottom = middle + 1;
622  }
623  }
624  /* Shouldn't be reached */
625  return -1;
626  }
627 
628  /**
629  Finds the index where the data associated with the given key is
630  found in the vector
631 
632  @param id ID of the data that needs to be found.
633 
634  @return Index where data for the provided ID is found. It
635  returns -1 if the key is not found in the data vector.
636  */
637  int binary_search_find(keyT id) const
638  {
639  int bottom = 0;
640  int top = data.size() - 1;
641  int middle;
642 
643  if ( data.size() == 0 ) return -1;
644  while ( bottom <= top ) {
645  middle = bottom + (top - bottom) / 2;
646  if ( id == data[middle] )
647  return middle;
648  else if ( id < data[middle] )
649  top = middle - 1;
650  else
651  bottom = middle + 1;
652  }
653  return -1;
654  }
655 
656  friend class ConfigGraph;
657 
658 public:
659  /**
660  Default constructor for SparseVectorMap
661  */
663 
664  /**
665  Constructor that allows you to pass an already filled in array
666  with data. The data in the passed in vector will be swapped
667  into the data vector of the SparseVectorMap and the passed in
668  vector will be empty.
669 
670  @param new_data Vector of data to swap into the SparseVectorMap
671  data
672 
673  @param sorted Specifies whether the vector is already sorted in
674  ascending order. If not, it will be sorted after swapping the
675  data in.
676  */
677  SparseVectorMap(std::vector<keyT>& new_data, bool sorted = false)
678  {
679  data.swap(new_data);
680  if ( !sorted ) {
681  std::sort(data.begin(), data.end, [](const keyT& lhs, const keyT& rhs) -> bool { return lhs < rhs; });
682  }
683  }
684 
685  typedef typename std::vector<keyT>::iterator iterator;
686  typedef typename std::vector<keyT>::const_iterator const_iterator;
687 
688  /**
689  Insert new value into SparseVectorMap. The inserted class must
690  have a key() function with return type keyT.
691 
692  @param val value to add to SparseVectorMap
693 
694  @return reference to the inserted item, or to the existing item
695  if it was already present in the map.
696 
697  */
698  keyT& insert(const keyT& val)
699  {
700  int index = binary_search_insert(val);
701  if ( index == -1 ) return data[binary_search_find(val)]; // already in the map
702  iterator it = data.begin();
703  it += index;
704  data.insert(it, val);
705  return data[index];
706  }
707 
708  /**
709  Returns the begin iterator to the underlying vector.
710 
711  @return begin iterator to data vector
712  */
713  iterator begin() { return data.begin(); }
714 
715  /**
716  Returns the end iterator to the underlying vector.
717 
718  @return end iterator to data vector
719  */
720  iterator end() { return data.end(); }
721 
722  /**
723  Returns the const begin iterator to the underlying vector.
724 
725  @return const begin iterator to data vector
726  */
727  const_iterator begin() const { return data.begin(); }
728 
729  /**
730  Returns the const end iterator to the underlying vector.
731 
732  @return const end iterator to data vector
733  */
734  const_iterator end() const { return data.end(); }
735 
736  /**
737  Checks if the provided id is found in the SparseVectorMap
738 
739  @param id id to check for
740 
741  @return true if id is found, false otherwise
742  */
743  bool contains(keyT id)
744  {
745  if ( binary_search_find(id) == -1 ) return false;
746  return true;
747  }
748 
749  /**
750  Operator returns a reference to data with the specified id.
751  Value can be modified. This will only return references to
752  existing values, you must use insert() for new values.
753 
754  @param id id of the value to return (value returned by key())
755 
756  @return reference to the requested item.
757 
758  */
759  keyT& operator[](keyT id)
760  {
761  int index = binary_search_find(id);
762  if ( index == -1 ) {
763  // Need to error out
764  }
765  return data[index];
766  }
767 
768  /**
769  Operator returns a const reference to data with the specified
770  id. Value cannot be modified. This will only return
771  references to existing values, you must use insert() for new
772  values.
773 
774  @param id id of the value to return (value returned by key())
775 
776  @return const reference to the requested item.
777 
778  */
779  const keyT& operator[](keyT id) const
780  {
781  int index = binary_search_find(id);
782  if ( index == -1 ) {
783  // Need to error out
784  }
785  return data[index];
786  }
787 
788  /**
789  Clears the contents of the SparseVectorMap
790  */
791  void clear() { data.clear(); }
792 
793  /**
794  Returns the number of items in the SparseVectorMap
795 
796  @return number of items
797  */
798  size_t size() { return data.size(); }
799 };
800 
801 } // namespace SST
802 
803 namespace SST {
804 namespace Core {
805 namespace Serialization {
806 
807 template <typename keyT, typename classT>
808 class serialize<SST::SparseVectorMap<keyT, classT>>
809 {
810 public:
811  void operator()(SST::SparseVectorMap<keyT, classT>& v, SST::Core::Serialization::serializer& ser) { ser& v.data; }
812 };
813 } // namespace Serialization
814 } // namespace Core
815 } // namespace SST
816 
817 #endif // SST_CORE_SPARSEVECTORMAP_H
iterator end()
Returns the end iterator to the underlying vector.
Definition: sparseVectorMap.h:720
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:43
iterator end()
Returns the end iterator to the underlying vector.
Definition: sparseVectorMap.h:445
classT & operator[](keyT id)
Operator returns a reference to data with the specified id.
Definition: sparseVectorMap.h:227
const_iterator begin() const
Returns the const begin iterator to the underlying vector.
Definition: sparseVectorMap.h:452
bool contains(keyT id)
Checks if the provided id is found in the SparseVectorMap.
Definition: sparseVectorMap.h:743
classT & insert(const classT &val)
Insert new value into SparseVectorMap.
Definition: sparseVectorMap.h:166
SparseVectorMap(std::vector< classT *> &new_data, bool sorted=false)
Constructor that allows you to pass an already filled in array with data.
Definition: sparseVectorMap.h:400
classT * operator[](keyT id)
Operator returns a reference to data with the specified id.
Definition: sparseVectorMap.h:484
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:389
Definition: action.cc:18
iterator end()
Returns the end iterator to the underlying vector.
Definition: sparseVectorMap.h:188
iterator begin()
Returns the begin iterator to the underlying vector.
Definition: sparseVectorMap.h:181
const_iterator end() const
Returns the const end iterator to the underlying vector.
Definition: sparseVectorMap.h:202
size_t size()
Returns the number of items in the SparseVectorMap.
Definition: sparseVectorMap.h:523
size_t size()
Returns the number of items in the SparseVectorMap.
Definition: sparseVectorMap.h:266
Serialization "gateway" object.
Definition: serialize.h:133
const classT * operator[](keyT id) const
Operator returns a const reference to data with the specified id.
Definition: sparseVectorMap.h:504
keyT & operator[](keyT id)
Operator returns a reference to data with the specified id.
Definition: sparseVectorMap.h:759
void filter(filterT &filt)
Function to filter the contents of the SparseVectorMap.
Definition: sparseVectorMap.h:542
SparseVectorMap(std::vector< keyT > &new_data, bool sorted=false)
Constructor that allows you to pass an already filled in array with data.
Definition: sparseVectorMap.h:677
iterator begin()
Returns the begin iterator to the underlying vector.
Definition: sparseVectorMap.h:438
const_iterator begin() const
Returns the const begin iterator to the underlying vector.
Definition: sparseVectorMap.h:727
const classT & operator[](keyT id) const
Operator returns a const reference to data with the specified id.
Definition: sparseVectorMap.h:247
SparseVectorMap(std::vector< classT > &new_data, bool sorted=false)
Constructor that allows you to pass an already filled in array with data.
Definition: sparseVectorMap.h:143
iterator begin()
Returns the begin iterator to the underlying vector.
Definition: sparseVectorMap.h:713
const keyT & operator[](keyT id) const
Operator returns a const reference to data with the specified id.
Definition: sparseVectorMap.h:779
keyT & insert(const keyT &val)
Insert new value into SparseVectorMap.
Definition: sparseVectorMap.h:698
size_t size()
Returns the number of items in the SparseVectorMap.
Definition: sparseVectorMap.h:798
const_iterator end() const
Returns the const end iterator to the underlying vector.
Definition: sparseVectorMap.h:459
SparseVectorMap()
Default constructor for SparseVectorMap.
Definition: sparseVectorMap.h:128
const_iterator begin() const
Returns the const begin iterator to the underlying vector.
Definition: sparseVectorMap.h:195
SparseVectorMap()
Default constructor for SparseVectorMap.
Definition: sparseVectorMap.h:662
bool contains(keyT id) const
Checks if the provided id is found in the SparseVectorMap.
Definition: sparseVectorMap.h:211
Class that stores data in a vector, but can access the data similar to a map.
Definition: sparseVectorMap.h:43
bool contains(keyT id) const
Checks if the provided id is found in the SparseVectorMap.
Definition: sparseVectorMap.h:468
void clear()
Clears the contents of the SparseVectorMap.
Definition: sparseVectorMap.h:791
Exception that is thrown by SparseVectorMap::filter() if the filtering object returns an object that ...
Definition: sparseVectorMap.h:275
SparseVectorMap()
Default constructor for SparseVectorMap.
Definition: sparseVectorMap.h:385
void clear()
Clears the contents of the SparseVectorMap.
Definition: sparseVectorMap.h:259
classT * insert(classT *val)
Insert new value into SparseVectorMap.
Definition: sparseVectorMap.h:423
const_iterator end() const
Returns the const end iterator to the underlying vector.
Definition: sparseVectorMap.h:734
void clear()
Clears the contents of the SparseVectorMap.
Definition: sparseVectorMap.h:516