Construct version 5.3.9
An agent based modeling framework
InteractionItem Struct Reference

Interaction Items is a container of three maps. Each map corresponds to a different datatype. More...

Public Types

enum class  item_keys : char {
  knowledge , alter , belief , ktm ,
  btm , ktrust , twitter_event , facebook_event ,
  feed_position , emotion
}
 
using attribute_iterator = std::unordered_set< item_keys >::iterator
 
using attribute_const_iterator = std::unordered_set< item_keys >::const_iterator
 
using index_iterator = std::unordered_map< item_keys, unsigned int >::iterator
 
using index_const_iterator = std::unordered_map< item_keys, unsigned int >::const_iterator
 
using value_iterator = std::unordered_map< item_keys, float >::iterator
 
using value_const_iterator = std::unordered_map< item_keys, float >::const_iterator
 

Public Member Functions

InteractionItemset_knowledge_item (unsigned int knowledge_index) noexcept
 Sets an item to become a knowledge item. More...
 
InteractionItemset_knowledgeTM_item (unsigned int knowledge_index, unsigned int alter_agent) noexcept
 Sets an item to become a knowledge transactive memory item. More...
 
InteractionItemset_belief_item (unsigned int belief_index, float belief_value) noexcept
 Sets an item to become a belief item. More...
 
InteractionItemset_beliefTM_item (unsigned int belief_index, unsigned int alter_agent, float belief_value) noexcept
 Sets an item to become a belief transactive memory item. More...
 
InteractionItemset_knowledge_trust_item (unsigned int knowledge_index, float ktrust) noexcept
 Sets an item to become a knowledge trust item. More...
 
bool get_knowledge_item (unsigned int &knowledge_index)
 Parses an item for knowledge More...
 
bool get_knowledgeTM_item (unsigned int &knowledge_index, unsigned int &alter_agent)
 Parses an item for knowledge transactive memory More...
 
bool get_belief_item (unsigned int &belief_index, float &belief_value)
 Parses an item for beliefs. More...
 
bool get_beliefTM_item (unsigned int &belief_index, unsigned int &alter_agent, float &belief_value)
 Parses an item for beliefs. More...
 
bool get_knowledge_trust_item (unsigned int &knowledge_index, float &ktrust)
 Parses an item for knowledge trust. More...
 
void clear (void) noexcept
 Clears all containers in item. More...
 

Static Public Member Functions

static const std::string & get_item_name (InteractionItem::item_keys key)
 
static InteractionItem create_knowledge_item (unsigned int knowledge_index) noexcept
 Creates a knowledge item using set_knowledge_item.

Parameters
knowledge_indexValue the "knowledge" key in indexes is set to.
Returns
Returns a newly created item.
Example: More...
 
static InteractionItem create_knowledgeTM_item (unsigned int knowledge_index, unsigned int alter_agent) noexcept
 Creates a knowledge transactive memory item using set_knowledgeTM_item. More...
 
static InteractionItem create_belief_item (unsigned int belief_index, float belief_value) noexcept
 Creates a belief item using set_beliefTM_item. More...
 
static InteractionItem create_beliefTM_item (unsigned int belief_index, unsigned int alter_agent, float belief_value) noexcept
 Creates a belief transactive memory item using set_beliefTM_item. More...
 
static InteractionItem create_knowledge_trust_item (unsigned int knowledge_index, float ktrust) noexcept
 Creates a knowledge trust item using set_knowledge_trust_item. More...
 

Public Attributes

std::unordered_map< item_keys, unsigned int > indexes
 
std::unordered_map< item_keys, float > values
 
std::unordered_set< item_keysattributes
 

Static Public Attributes

static std::unordered_map< InteractionItem::item_keys, std::string > item_names
 

Detailed Description

Interaction Items is a container of three maps. Each map corresponds to a different datatype.

  • The attributes map holds a map with strings as keys to booleans. The booleans are a placeholder and are irrelevant for most purposes. Instead the presence of a key in the map corresponds to an item having that attribute.
  • The indexes map holds a map with strings as keys to unsigned ints.
  • The values map holds a map with strings as keys to floats.

Member Enumeration Documentation

◆ item_keys

enum class InteractionItem::item_keys : char
strong

Keys used for an InteractionItem.

Member Function Documentation

◆ clear()

void InteractionItem::clear ( void  )
noexcept

Clears all containers in item.

attributes, indexes, and values are cleared using unordered_map::clear.

Example

void print_item( InteractionItem item ) {
unsigned int knowledge, belief_index;
float belief_value;
std::cout << "This item contains:" << std::endl;
if( item.get_belief_item(belief_index, belief_value) ) {
std::cout << "belief index: " << belief_index << std::endl;
std::cout << "belief value: " << belief_value << std::endl;
}
if ( item.get_knowledge_item(knowledge) ) {
std::cout << "knowledge index: " << knowledge << std::endl;
}
};
int main()
{
print_item(item);
item.set_belief_item(4, 0.3);
print_item(item);
item.clear();
item.set_belief_item(6, 0.2);
print_item(item);
}
Interaction Items is a container of three maps. Each map corresponds to a different datatype.
Definition: InteractionMessage.h:39
bool get_belief_item(unsigned int &belief_index, float &belief_value)
Parses an item for beliefs.
Definition: InteractionMessage.cpp:124
void clear(void) noexcept
Clears all containers in item.
Definition: InteractionMessage.cpp:187
bool get_knowledge_item(unsigned int &knowledge_index)
Parses an item for knowledge
Definition: InteractionMessage.cpp:88
InteractionItem & set_belief_item(unsigned int belief_index, float belief_value) noexcept
Sets an item to become a belief item.
Definition: InteractionMessage.cpp:41
InteractionItem & set_knowledge_item(unsigned int knowledge_index) noexcept
Sets an item to become a knowledge item.
Definition: InteractionMessage.cpp:27

Output:

This item contains:
knowledge index 5
This item contains:
knowledge index: 5
belief index: 3
belief value: 0.4
This item contains:
belief index: 5
belief value: 0.2

Complexity

Linear in container size of attributes, indexes, and values.

Iterator validity

All iterators, pointers, and references are invalidated.

Exception Safety

This member function never throws exceptions.

◆ create_belief_item()

InteractionItem InteractionItem::create_belief_item ( unsigned int  belief_index,
float  belief_value 
)
staticnoexcept

Creates a belief item using set_beliefTM_item.

Parameters
belief_indexValue the "belief" key in indexes is set to.
belief_valueValue the "belief" key in values is set to.
Returns
Returns the newly created item.

Example

int main()
{
std::cout << "This item contains:" << std::endl;
unsigned int b;
float belief;
if(item.get_belief_item(b, belief)) {
std::cout << "belief index: " << b << std::endl;
std::cout << "belief value: " << belief << std::endl;
}
}
static InteractionItem create_belief_item(unsigned int belief_index, float belief_value) noexcept
Creates a belief item using set_beliefTM_item.
Definition: InteractionMessage.cpp:73

Output:

This item contains:
belief index: 5
belief value: 0.3

Complexity

This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes and values.

Iterator validity

In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.

Exception Safety

This member function never throws exceptions.

Here is the call graph for this function:

◆ create_beliefTM_item()

InteractionItem InteractionItem::create_beliefTM_item ( unsigned int  belief_index,
unsigned int  alter_agent,
float  belief_value 
)
staticnoexcept

Creates a belief transactive memory item using set_beliefTM_item.

Parameters
belief_indexValue the "belief" key in indexes is set to.
alter_agentValue the "alter" key in indexes is set to.
belief_valueValue the "belief" key in values is set to.
Returns
Returns the newly created item.

Example

int main()
{
std::cout << "This item contains:" << std::endl;
unsigned int b, alter;
float belief;
if(item.get_beliefTM_item(b, alter, belief)) {
std::cout << "belief index: " << b << std::endl;
std::cout << "alter agent index: " << alter << std::endl;
std::cout << "belief value: " << belief << std::endl;
}
}
static InteractionItem create_beliefTM_item(unsigned int belief_index, unsigned int alter_agent, float belief_value) noexcept
Creates a belief transactive memory item using set_beliefTM_item.
Definition: InteractionMessage.cpp:78
bool get_beliefTM_item(unsigned int &belief_index, unsigned int &alter_agent, float &belief_value)
Parses an item for beliefs.
Definition: InteractionMessage.cpp:143

Output:

This item contains:
belief index: 5
alter agent index: 4
belief value: 0.3

Complexity

This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes, and values.

Iterator validity

In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.

Exception Safety

This member function never throws exceptions.

Here is the call graph for this function:

◆ create_knowledge_item()

InteractionItem InteractionItem::create_knowledge_item ( unsigned int  knowledge_index)
staticnoexcept

Creates a knowledge item using set_knowledge_item.

Parameters
knowledge_indexValue the "knowledge" key in indexes is set to.
Returns
Returns a newly created item.
Example:

int main()
{
std::cout &lt;&lt; "This item contains:" &lt;&lt; std::endl;
unsigned int k;
if(item.get_knowledge_item(k)) {
std::cout &lt;&lt; "knowledge index: " << k << std::endl;
}
}
static InteractionItem create_knowledge_item(unsigned int knowledge_index) noexcept
Creates a knowledge item using set_knowledge_item. Value the "knowledge" key in indexes is set to....
Definition: InteractionMessage.cpp:63

Output:

This item contains:
knowledge index: 5

Complexity

This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes and indexes.

Iterator validity

No changes to iterators for values. In most cases, all iterators in the attributes and indexes container remain valid with the only exception when either container is rehashed. See unordered_map::insert for further details.

Exception Safety

This member function never throws exceptions.

Here is the call graph for this function:

◆ create_knowledge_trust_item()

InteractionItem InteractionItem::create_knowledge_trust_item ( unsigned int  knowledge_index,
float  ktrust 
)
staticnoexcept

Creates a knowledge trust item using set_knowledge_trust_item.

Parameters
knowledge_indexValue the "knowledge" key in indexes is set to.
ktrustValue the "knowledge trust" key in values is set to.
Returns
Returns the newly created item.

Example

int main()
{
std::cout << "This item contains:" << std::endl;
unsigned int k;
float ktrust;
if(item.get_knowledge_trust_item(k, ktrust)) {
std::cout << "knowledge index: " << k << std::endl;
std::cout << "knowledge trust value: " << ktrust << std::endl;
}
}
bool get_knowledge_trust_item(unsigned int &knowledge_index, float &ktrust)
Parses an item for knowledge trust.
Definition: InteractionMessage.cpp:165
static InteractionItem create_knowledge_trust_item(unsigned int knowledge_index, float ktrust) noexcept
Creates a knowledge trust item using set_knowledge_trust_item.
Definition: InteractionMessage.cpp:83

Output:

This item contains:
knowledge index: 5
knowledge trust value: 0.3

Complexity

This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes and values.

Iterator validity

In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.

Exception Safety

This member function never throws exceptions.

Here is the call graph for this function:

◆ create_knowledgeTM_item()

InteractionItem InteractionItem::create_knowledgeTM_item ( unsigned int  knowledge_index,
unsigned int  alter_agent 
)
staticnoexcept

Creates a knowledge transactive memory item using set_knowledgeTM_item.

Parameters
knowledge_indexValue the "knowledge" key in indexes is set to.
alter_agentValue the "alter" key in indexes is set to.
Returns
Returns the newly created item.

Example

int main()
{
std::cout << "This item contains:" << std::endl;
unsigned int k, alter;
if(item.get_knowledgeTM_item(k, alter)) {
std::cout << "knowledge index: " << k << std::endl;
std::cout << "alter agent index: " << alter << std::endl;
}
}
static InteractionItem create_knowledgeTM_item(unsigned int knowledge_index, unsigned int alter_agent) noexcept
Creates a knowledge transactive memory item using set_knowledgeTM_item.
Definition: InteractionMessage.cpp:68
bool get_knowledgeTM_item(unsigned int &knowledge_index, unsigned int &alter_agent)
Parses an item for knowledge transactive memory
Definition: InteractionMessage.cpp:103

Output:

This item contains:
knowledge index: 5
alter agent index: 4

Complexity

This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes and indexes.

Iterator validity

No changes to iterators for values. In most cases, all iterators in the attributes and indexes container remain valid with the only exception when either container is rehashed. See unordered_map::insert for further details.

Exception Safety

This member function never throws exceptions.

Here is the call graph for this function:

◆ get_belief_item()

bool InteractionItem::get_belief_item ( unsigned int &  belief_index,
float &  belief_value 
)

Parses an item for beliefs.

Parses an item to determine if the item is about a belief. This is done by searching for the "belief" key in the variable attributes.

Parameters
belief_indexParameter is set to the value at key "belief" in variable indexes if the key "belief" was found in variable attributes was found.
belief_valueParameter is set to the value at key "belief" in variable values if the key "belief" was found in variable attributes was found.
Returns
Returns true if the "belief" key was found in attributes. Otherwise, returns false.

Example

int main()
{
item.attributes.insert(item_keys::belief);
item.indexes[item_keys::belief] = 3;
item.values[item_keys::belief] = 0.4;
unsigned int belief_index;
float belief_value;
std::cout << "This item contains:" << std::endl;
if( item.get_belief_item(belief_index, belief_value) ) {
std::cout << "belief index: " << belief_index << std::endl;
std::cout << "belief value: " << belief_value << std::endl;
}
}
std::unordered_map< item_keys, float > values
Definition: InteractionMessage.h:998
std::unordered_map< item_keys, unsigned int > indexes
Definition: InteractionMessage.h:994
std::unordered_set< item_keys > attributes
Definition: InteractionMessage.h:1002

Output:

This item contains:
belief index: 3
belief value: 0.4

Complexity

This function uses unordered_map::find.
Average case: constant.
Worst case: linear in container size of attributes, indexes, and values.

Iterator validity

No changes.

Exception Safety

An assertion is raised when an item contains the key "belief" in attributes, but key "belief" was not present in either indexes and/or values.

◆ get_beliefTM_item()

bool InteractionItem::get_beliefTM_item ( unsigned int &  belief_index,
unsigned int &  alter_agent,
float &  belief_value 
)

Parses an item for beliefs.

Parses an item to determine if the item is about a belief. This is done by searching for the "belief" key in attributes.

Parameters
belief_indexParameter is set to the value at key "belief" in variable indexes if the key "beliefTM" was found in variable attributes was found.
alter_agentParameter is set to the value at key "alter" in variable indexes if the key "beliefTM" was found in variable attributes was found.
belief_valueParameter is set to the value at key "belief" in variable values if the key "beliefTM" was found in variable attributes was found.
Returns
Returns true if the "beliefTM" key was found in attributes. Otherwise, returns false.

Example

int main()
{
item.attributes.insert(item_keys::btm);
item.indexes[item_keys::belief] = 3;
item.indexes[item_keys::alter] = 5;
item.values[item_keys::belief] = 0.4;
unsigned int belief_index, alter;
float belief_value;
std::cout << "This item contains:" << std::endl;
if( item.get_beliefTM_item(belief_index, alter, belief_value) ) {
std::cout << "belief index: " << belief_index << std::endl;
std::cout << "alter agent index: " << alter << std::endl;
std::cout << "belief value: " << belief_value << std::endl;
}
}

Output:

This item contains:
belief index: 3
alter agent index: 5
belief value: 0.4

Complexity

This function uses unordered_map::find.
Average case: constant.
Worst case: linear in container size of attributes, indexes, and values.

Iterator validity

No changes.

Exception Safety

An assertion is raised when an item contains the key "beliefTM" in attributes, but the keys "belief" and/or "alter" were not present in indexes and/or the key "belief" was not present in values.

◆ get_item_name()

const std::string & InteractionItem::get_item_name ( InteractionItem::item_keys  key)
static

Returns the name of the key;

◆ get_knowledge_item()

bool InteractionItem::get_knowledge_item ( unsigned int &  knowledge_index)

Parses an item for knowledge

Parses an item to determine if the item is about knowledge. This is done by searching for the "knowledge" key in attributes.

Parameters
knowledge_indexIf the "knowledge" key was found in attributes, knowledge_index is set to the entry in indexes with key "knowledge". knowledge_index is unmodified if the key was not found in attributes.
Returns
Returns true if the "knowledge" key was found in attributes. Otherwise, returns false.

Example

int main()
{
item.attributes.insert(item_keys::knowledge);
item.indexes[item_keys::knowledge] = 3;
unsigned int knowledge;
std::cout << "This item contains:" << std::endl;
if( item.get_knowledge_item(knowledge) ) {
std::cout << "knowledge index: " << knowledge << std::endl;
}
}

Output:

This item contains:
knowledge index: 3

Complexity

This function uses unordered_map::find.
Average case: constant.
Worst case: linear in container size of attributes and indexes.

Iterator validity

No changes.

Exception Safety

An assertion is raised when an item contains the key "knowledge" in attributes, but the key "knowledge" was not present in indexes.

◆ get_knowledge_trust_item()

bool InteractionItem::get_knowledge_trust_item ( unsigned int &  knowledge_index,
float &  ktrust 
)

Parses an item for knowledge trust.

Parses an item to determine if the item is about a knowledge trust. This is done by searching for the "knowledge trust" key in the variable attributes.

Parameters
knowledge_indexParameter is set to the value at key "knowledge" in variable indexes if the key "knowledge trust" was found in variable attributes was found.
ktrustParameter is set to the value at key "knowledge trust" in variable values if the key "knowledge trust" was found in variable attributes was found.
Returns
Returns true if the "knowledge trust" key was found in attributes. Otherwise, returns false.

Example

int main()
{
item.attributes.insert(item_keys::ktrust);
item.indexes[item_keys::knowledge] = 3;
item.values[item_keys::ktrust] = 0.4;
unsigned int knowledge_index;
float ktrust;
std::cout << "This item contains:" << std::endl;
if( item.get_knowledge_trust_item(knowledge_index, ktrust) ) {
std::cout << "knowledge index: " << knowledge_index << std::endl;
std::cout << "knowledge trust: " << ktrust << std::endl;
}
}

Output:

This item contains:
knowledge index: 3
knowledge trust: 0.4

Complexity

This function uses unordered_map::find.
Average case: constant.
Worst case: linear in container size of attributes, indexes, and values.

Iterator validity

No changes.

Exception Safety

An assertion is raised when an item contains the key "knowledge trust" in attributes, but key "knowledge" was not present in indexes and/or key "knowledge trust" was not present in values.

◆ get_knowledgeTM_item()

bool InteractionItem::get_knowledgeTM_item ( unsigned int &  knowledge_index,
unsigned int &  alter_agent 
)

Parses an item for knowledge transactive memory

Parses an item to determine if the item is about knowledge transactive memory. This is done by searching for the "knowledgeTM" key in attributes.

Parameters
knowledge_indexParameter is set to the value found at key "knowledge" in the indexes variable if the "knowledgeTM" key was found in attributes.
alter_agentParameter is set to the value found at key "alter" in the indexes variable if the "knowledgeTM" key was found in attributes.
Returns
Returns true if the "knowledgeTM" key was found in attributes. Otherwise, returns false.

Example

int main()
{
item.attributes.insert(item_keys::ktm);
item.indexes[item_keys::knowledge] = 3;
item.indexes[item_keys::alter] = 4;
unsigned int knowledge, alter;
std::cout << "This item contains:" << std::endl;
if( item.get_knowledge_item(knowledge, alter) ) {
std::cout << "knowledge index: " << knowledge << std::endl;
std::cout << "alter agent index: " << alter << std::endl;
}
}

Output:

This item contains:
knowledge index: 3
alter agent index: 4

Complexity

This function uses unordered_map::find.
Average case: constant.
Worst case: linear in container size of attributes and indexes.

Iterator validity

No changes.

Exception Safety

An assertion is raised when an item contains the key "knowledgeTM" in attributes, but either key "knowledge" or "alter" was not present in indexes.

◆ set_belief_item()

InteractionItem & InteractionItem::set_belief_item ( unsigned int  belief_index,
float  belief_value 
)
noexcept

Sets an item to become a belief item.

Adds keys to the item's unordered maps to signify the item is about a belief and what indexes and values the item corresponds to. Belief items are indicated by the presence of the "belief" key in attributes. Elements at keys "belief" in attributes, "belief" in indexes, and "belief" in values are overwritten.

Parameters
belief_indexValue the "belief" key in indexes is set to.
belief_valueValue the "belief" key in values is set to.
Returns
Returns the updated item.

Example

int main()
{
item.set_belief_item(5, 0.3);
std::cout << "This item contains:" << std::endl;
unsigned int b;
float belief;
if(item.get_belief_item(b, belief)) {
std::cout << "belief index: " << b << std::endl;
std::cout << "belief value: " << belief << std::endl;
}
}

Output:

This item contains:
belief index: 5
belief value: 0.3

Complexity

This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes and values.

Iterator validity

In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.

Exception Safety

This member function never throws exceptions.

Here is the caller graph for this function:

◆ set_beliefTM_item()

InteractionItem & InteractionItem::set_beliefTM_item ( unsigned int  belief_index,
unsigned int  alter_agent,
float  belief_value 
)
noexcept

Sets an item to become a belief transactive memory item.

Adds keys to the item's unordered maps to signify the item is about a belief transactive memory and what indexes and values the item corresponds to. Belief transactive memory items are indicated by the presence of the "beliefTM" key in attributes. Elements at keys "beliefTM" in attributes, "belief" and "alter" in indexes, and "belief" in values are overwritten.

Parameters
belief_indexValue the "belief" key in indexes is set to.
alter_agentValue the "alter" key in indexes is set to.
belief_valueValue the "belief" key in values is set to.
Returns
Returns the updated item.

Example

int main()
{
item.set_beliefTM_item(5, 4, 0.3);
std::cout << "This item contains:" << std::endl;
unsigned int b, alter;
float belief;
if(item.get_beliefTM_item(b, alter, belief)) {
std::cout << "belief index: " << b << std::endl;
std::cout << "alter agent index: " << alter << std::endl;
std::cout << "belief value: " << belief << std::endl;
}
}
InteractionItem & set_beliefTM_item(unsigned int belief_index, unsigned int alter_agent, float belief_value) noexcept
Sets an item to become a belief transactive memory item.
Definition: InteractionMessage.cpp:48

Output:

This item contains:
belief index: 5
alter agent index: 4
belief value: 0.3

Complexity

This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes, and values.

Iterator validity

In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.

Exception Safety

This member function never throws exceptions.

Here is the caller graph for this function:

◆ set_knowledge_item()

InteractionItem & InteractionItem::set_knowledge_item ( unsigned int  knowledge_index)
noexcept

Sets an item to become a knowledge item.

Adds keys to the item's unordered maps to signify the item is about knowledge and what indexes the item corresponds to. Knowledge items are indicated by the presence of the "knowledge" key in attributes. Elements at keys "knowledge" in attributes and "knowledge" in indexes are overwritten.

Parameters
knowledge_indexValue the "knowledge" key in indexes is set to.
Returns
Returns the updated item.

Example:

int main()
{
std::cout << "This item contains:" << std::endl;
unsigned int k;
if(item.get_knowledge_item(k)) {
std::cout << "knowledge index: " << k << std::endl;
}
}

Output:

This item contains:
knowledge index: 5

Complexity

This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes and indexes.

Iterator validity

No changes to iterators for values. In most cases, all iterators in the attributes and indexes container remain valid with the only exception when either container is rehashed. See unordered_map::insert for further details.

Exception Safety

This member function never throws exceptions.

Here is the caller graph for this function:

◆ set_knowledge_trust_item()

InteractionItem & InteractionItem::set_knowledge_trust_item ( unsigned int  knowledge_index,
float  ktrust 
)
noexcept

Sets an item to become a knowledge trust item.

Adds keys to the item's unordered maps to signify the item is about a the trust of a piece of knowledge and what indexes and values the item corresponds to. Knowledge trust items are indicated by the presence of the "knowledge trust" key in attributes. Elements at keys "knowledge trust" in attributes, "knowledge" in indexes, and "knowledge trust" in values are overwritten.

Parameters
knowledge_indexValue the "knowledge" key in indexes is set to.
ktrustValue the "knowledge trust" key in values is set to.
Returns
Returns the updated item.

Example

int main()
{
std::cout << "This item contains:" << std::endl;
unsigned int k;
float ktrust;
if(item.get_knowledge_trust_item(k, ktrust)) {
std::cout << "knowledge index: " << k << std::endl;
std::cout << "knowledge trust value: " << ktrust << std::endl;
}
}
InteractionItem & set_knowledge_trust_item(unsigned int knowledge_index, float ktrust) noexcept
Sets an item to become a knowledge trust item.
Definition: InteractionMessage.cpp:56

Output:

This item contains:
knowledge index: 5
knowledge trust value: 0.3

Complexity

This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes, indexes and values.

Iterator validity

In most cases, all iterators in the attributes, indexes, and values container remain valid with the only exception when any container is rehashed. See unordered_map::insert for further details.

Exception Safety

This member function never throws exceptions.

Here is the caller graph for this function:

◆ set_knowledgeTM_item()

InteractionItem & InteractionItem::set_knowledgeTM_item ( unsigned int  knowledge_index,
unsigned int  alter_agent 
)
noexcept

Sets an item to become a knowledge transactive memory item.

Adds keys to the item's unordered maps to signify the item is about knowledge transactive memory and what indexes the item corresponds to. Knowledge transactive memory items are indicated by the presence of the "knowledgeTM" key in attributes. Elements at keys "knowledgeTM" in attributes and "knowledge" and "alter" in indexes are overwritten.

Parameters
knowledge_indexValue the "knowledge" key in indexes is set to.
alter_agentValue the "alter" key in indexes is set to.
Returns
Returns the updated item.

Example

int main()
{
std::cout << "This item contains:" << std::endl;
unsigned int k, alter;
if(item.get_knowledgeTM_item(k, alter)) {
std::cout << "knowledge index: " << k << std::endl;
std::cout << "alter agent index: " << alter << std::endl;
}
}
InteractionItem & set_knowledgeTM_item(unsigned int knowledge_index, unsigned int alter_agent) noexcept
Sets an item to become a knowledge transactive memory item.
Definition: InteractionMessage.cpp:33

Output:

This item contains:
knowledge index: 5
alter agent index: 4

Complexity

This function uses unordered_map::insert.
Average case: constant.
Worst case: linear in container size of attributes and indexes.

Iterator validity

No changes to iterators for values. In most cases, all iterators in the attributes and indexes container remain valid with the only exception when either container is rehashed. See unordered_map::insert for further details.

Exception Safety

This member function never throws exceptions.

Here is the caller graph for this function:

Member Data Documentation

◆ item_names

std::unordered_map< InteractionItem::item_keys, std::string > InteractionItem::item_names
static
Initial value:
{
{InteractionItem::item_keys::knowledge, "knowledge"},
{InteractionItem::item_keys::alter, "alter"},
{InteractionItem::item_keys::belief, "belief"},
{InteractionItem::item_keys::ktm, "knowledgeTM"},
{InteractionItem::item_keys::btm, "beliefTM"},
{InteractionItem::item_keys::ktrust, "knowledge trust"},
{InteractionItem::item_keys::twitter_event, "twitter event"},
{InteractionItem::item_keys::facebook_event,"facebook event"},
{InteractionItem::item_keys::feed_position, "feed position"},
}