Class that stores data in a vector, but can access the data similar to a map.
More...
|
|
| SparseVectorMap () |
| | Default constructor for SparseVectorMap.
|
| |
| | SparseVectorMap (std::vector< classT * > &new_data, bool sorted=false) |
| | Constructor that allows you to pass an already filled in array with data.
|
| |
| classT * | insert (classT *val) |
| | Insert new value into SparseVectorMap.
|
| |
| iterator | begin () |
| | Returns the begin iterator to the underlying vector.
|
| |
| iterator | end () |
| | Returns the end iterator to the underlying vector.
|
| |
| const_iterator | begin () const |
| | Returns the const begin iterator to the underlying vector.
|
| |
| const_iterator | end () const |
| | Returns the const end iterator to the underlying vector.
|
| |
| bool | contains (keyT id) const |
| | Checks if the provided id is found in the SparseVectorMap.
|
| |
| classT * | operator[] (keyT id) |
| | Operator returns a reference to data with the specified id.
|
| |
| const classT * | operator[] (keyT id) const |
| | Operator returns a const reference to data with the specified id.
|
| |
|
void | clear () |
| | Clears the contents of the SparseVectorMap.
|
| |
| size_t | size () |
| | Returns the number of items in the SparseVectorMap.
|
| |
| template<typename filterT> |
| void | filter (filterT &filt) |
| | Function to filter the contents of the SparseVectorMap.
|
| |
|
| SparseVectorMap () |
| | Default constructor for SparseVectorMap.
|
| |
| | SparseVectorMap (std::vector< classT > &new_data, bool sorted=false) |
| | Constructor that allows you to pass an already filled in array with data.
|
| |
| classT & | insert (const classT &val) |
| | Insert new value into SparseVectorMap.
|
| |
| iterator | begin () |
| | Returns the begin iterator to the underlying vector.
|
| |
| const_iterator | begin () const |
| | Returns the const begin iterator to the underlying vector.
|
| |
| iterator | end () |
| | Returns the end iterator to the underlying vector.
|
| |
| const_iterator | end () const |
| | Returns the const end iterator to the underlying vector.
|
| |
| bool | contains (keyT id) const |
| | Checks if the provided id is found in the SparseVectorMap.
|
| |
| classT & | operator[] (keyT id) |
| | Operator returns a reference to data with the specified id.
|
| |
| const classT & | operator[] (keyT id) const |
| | Operator returns a const reference to data with the specified id.
|
| |
|
void | clear () |
| | Clears the contents of the SparseVectorMap.
|
| |
| size_t | size () |
| | Returns the number of items in the SparseVectorMap.
|
| |
template<typename keyT, typename classT>
class SST::SparseVectorMap< keyT, classT * >
Class that stores data in a vector, but can access the data similar to a map.
The data structure is O(log n) on reads, but is O(n) to insert. The primary use case is when data is inserted in order, but accessed randomly. You can also create the SparseVectorMap with a vector already loaded with the data. If the data is not already sorted, it will call std::sort on the data, which likely has an average complexity of O(n log n). This data structure should not be used for large lists where inserts do not happen in sorted order.
NOTE: Since the data is stored in the vector, reference returned from the various accessor functions will not be valid longterm. If an insert causes the vector to be resized, all references returned before that reallocation may (likely will) be invalid. References are only guaranteed to be valid until the next write to the data structure.
template<typename keyT, typename classT>
template<typename filterT>
Function to filter the contents of the SparseVectorMap.
Takes an object with an overloaded operator() function that takes as argument the current item. The funtion returns the object that should take the place of this object (value returned by key() function must be same for both objects), or returns nullptr if the object should be deleted. When an item is deleted, the size of the map reduces by 1.
- Parameters
-
| filt | Filter object to use for filtering contents of map |
- Exceptions
-
| bad_filtered_key_error | filter returned an object that didn't return the same value on a call to key() as the original object in the map. |