SST
13.0.0
StructuralSimulationToolkit
|
Class that stores data in a vector, but can access the data similar to a map. More...
#include <sparseVectorMap.h>
Public Types | |
typedef std::vector< classT >::iterator | iterator |
typedef std::vector< classT >::const_iterator | const_iterator |
Public Member Functions | |
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. More... | |
classT & | insert (const classT &val) |
Insert new value into SparseVectorMap. More... | |
iterator | begin () |
Returns the begin iterator to the underlying vector. More... | |
iterator | end () |
Returns the end iterator to the underlying vector. More... | |
const_iterator | begin () const |
Returns the const begin iterator to the underlying vector. More... | |
const_iterator | end () const |
Returns the const end iterator to the underlying vector. More... | |
bool | contains (keyT id) const |
Checks if the provided id is found in the SparseVectorMap. More... | |
classT & | operator[] (keyT id) |
Operator returns a reference to data with the specified id. More... | |
const classT & | operator[] (keyT id) const |
Operator returns a const reference to data with the specified id. More... | |
void | clear () |
Clears the contents of the SparseVectorMap. | |
size_t | size () |
Returns the number of items in the SparseVectorMap. More... | |
Friends | |
class | SST::Core::Serialization::serialize< SparseVectorMap< keyT, classT > > |
class | ConfigGraph |
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.
|
inline |
Constructor that allows you to pass an already filled in array with data.
The data in the passed in vector will be swapped into the data vector of the sparsevectormap and the passed in vector will be empty.
new_data | Vector of data to swap into the sparsevectormap data |
sorted | Specifies whether the vector is already sorted in ascending order. if not, it will be sorted after swapping the data in. |
|
inline |
Returns the begin iterator to the underlying vector.
Referenced by SST::IMPL::Partition::SSTRoundRobinPartition::performPartition(), SST::IMPL::Partition::SimplePartitioner::performPartition(), SST::IMPL::Partition::SSTLinearPartition::performPartition(), SST::PartitionGraph::print(), and SST::Simulation_impl::processGraphInfo().
|
inline |
Returns the const begin iterator to the underlying vector.
|
inline |
Checks if the provided id is found in the SparseVectorMap.
id | id to check for |
|
inline |
Returns the end iterator to the underlying vector.
Referenced by SST::IMPL::Partition::SSTRoundRobinPartition::performPartition(), SST::IMPL::Partition::SimplePartitioner::performPartition(), SST::IMPL::Partition::SSTLinearPartition::performPartition(), SST::PartitionGraph::print(), and SST::Simulation_impl::processGraphInfo().
|
inline |
Returns the const end iterator to the underlying vector.
|
inline |
Insert new value into SparseVectorMap.
The inserted class must have a key() function with return type keyT.
val | value to add to SparseVectorMap |
Referenced by SST::IMPL::Partition::SimplePartitioner::performPartition().
|
inline |
Operator returns a reference to data with the specified id.
Value can be modified. This will only return references to existing values, you must use insert() for new values.
id | id of the value to return (value returned by key()) |
|
inline |
Operator returns a const reference to data with the specified id.
Value cannot be modified. This will only return references to existing values, you must use insert() for new values.
id | id of the value to return (value returned by key()) |
|
inline |
Returns the number of items in the SparseVectorMap.