SST  13.1.0
Structural Simulation Toolkit
SST::Shared::SharedSet< valT > Class Template Reference

SharedSet class. More...

#include <sharedSet.h>

Inheritance diagram for SST::Shared::SharedSet< valT >:
SST::Shared::SharedObject

Public Types

typedef std::set< valT >::const_iterator const_iterator
 
typedef std::set< valT >::const_reverse_iterator const_reverse_iterator
 
- Public Types inherited from SST::Shared::SharedObject
enum  verify_type { VERIFY_UNINITIALIZED , FE_VERIFY , INIT_VERIFY , NO_VERIFY }
 Enum of verify types.
 

Public Member Functions

int initialize (const std::string &obj_name, verify_type v_type)
 Initialize the SharedSet. More...
 
size_t size () const
 Get the size of the set. More...
 
bool empty () const
 Tests if the set is empty. More...
 
size_t count (const valT &k) const
 Counts elements with a specific value. More...
 
const_iterator begin () const
 Get const_iterator to beginning of underlying set.
 
const_iterator end () const
 Get const_iterator to end of underlying set.
 
const_reverse_iterator rbegin () const
 Get const_reverse_iterator to beginning of underlying set.
 
const_reverse_iterator rend () const
 Get const_reverse_iterator to end of underlying set.
 
void publish ()
 Indicate that the calling element has written all the data it plans to write. More...
 
bool isFullyPublished ()
 Check whether all instances of this SharedSet have called publish(). More...
 
void insert (const valT &value)
 Insert data to the set. More...
 
const_iterator find (const valT &value) const
 Searches the SharedSet for an element equivalent to value and returns a const iterator to it if found, otherwise it returns an iterator to SharedSet::end. More...
 
const valT & mutex_find (const valT &value) const
 Searches the SharedSet for an element equivalent to value and returns a const iterator to it if found, otherwise it returns an iterator to SharedSet::end. More...
 

Additional Inherited Members

- Protected Member Functions inherited from SST::Shared::SharedObject
void incPublishCount (SharedObjectData *data)
 
int incShareCount (SharedObjectData *data)
 
- Static Protected Attributes inherited from SST::Shared::SharedObject
static SharedObjectDataManager manager
 

Detailed Description

template<typename valT>
class SST::Shared::SharedSet< valT >

SharedSet class.

The class is templated to allow for an array of any non-pointer type. The type must be serializable.

Member Function Documentation

◆ count()

template<typename valT >
size_t SST::Shared::SharedSet< valT >::count ( const valT &  k) const
inline

Counts elements with a specific value.

Becuase this is not a multiset, it will either return 1 or 0.

Returns
Count of elements with specified value

◆ empty()

template<typename valT >
bool SST::Shared::SharedSet< valT >::empty ( ) const
inline

Tests if the set is empty.

Returns
true if set is empty, false otherwise

◆ find()

template<typename valT >
const_iterator SST::Shared::SharedSet< valT >::find ( const valT &  value) const
inline

Searches the SharedSet for an element equivalent to value and returns a const iterator to it if found, otherwise it returns an iterator to SharedSet::end.

Parameters
valuevalue to search for

NOTE: This function does not use a mutex, so it is possible to get invalid results if another thread is simulateously writing to the set. However, after the init() phase of simulation is complete (in setup() and beyond), this is always a safe operation. If reading during init() and you can't guarantee that all elements have already written all elements to the SharedSet, use mutex_find() to guarantee thread safety.

Returns
read-only iterator to data referenced by value

◆ initialize()

template<typename valT >
int SST::Shared::SharedSet< valT >::initialize ( const std::string &  obj_name,
verify_type  v_type 
)
inline

Initialize the SharedSet.

Parameters
obj_nameName of the object. This name is how the object is uniquely identified across ranks.
verify_modeSpecifies how multiply written data should be verified. Since the underlying set knows if the data has already been written, FE_VERIFY and INIT_VERIFY simply use this built-in mechanism to know when an item has previously been written. When these modes are enabled, multiply written data must match what was written before. When NO_VERIFY is passed, no verification will occur. This is mostly useful when you can guarantee that multiple elements won't write the same value and you want to do in-place modifications as you initialize. VERIFY_UNINITIALIZED is a reserved value and should not be passed.
Returns
returns the number of instances that have intialized themselve before this instance on this MPI rank.

◆ insert()

template<typename valT >
void SST::Shared::SharedSet< valT >::insert ( const valT &  value)
inline

Insert data to the set.

This function is thread-safe, as a mutex is used to ensure only one insert at a time.

Parameters
valvalue of the insert

◆ isFullyPublished()

template<typename valT >
bool SST::Shared::SharedSet< valT >::isFullyPublished ( )
inline

Check whether all instances of this SharedSet have called publish().

NOTE: Is is possible that this could return true one round, but false the next if a new instance of the SharedSet was initialized but not published after the last call.

◆ mutex_find()

template<typename valT >
const valT& SST::Shared::SharedSet< valT >::mutex_find ( const valT &  value) const
inline

Searches the SharedSet for an element equivalent to value and returns a const iterator to it if found, otherwise it returns an iterator to SharedSet::end.

This version of find is always thread safe (

See also
find()).
Parameters
valuevalue to search for
Returns
read-only iterator to data reference by value

◆ publish()

template<typename valT >
void SST::Shared::SharedSet< valT >::publish ( )
inline

Indicate that the calling element has written all the data it plans to write.

Writing to the set through this instance after publish() is called will create an error.

◆ size()

template<typename valT >
size_t SST::Shared::SharedSet< valT >::size ( ) const
inline

Get the size of the set.

Returns
size of the set

The documentation for this class was generated from the following file: