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