template<typename IndexT>
vt::vrt::collection::Holder struct

Hold collection elements mapped to this node for a given collection.

Store the unique pointers to collection elements for a given collection proxy. Provides functionality to find, add, remove, and foreach over the collection elements.

Public types

template<typename T, typename U>
using ContType = std::unordered_map<T, U>
using CollectionType = Indexable<IndexT>
using VirtualPtrType = std::unique_ptr<CollectionType>
using LookupElementType = IndexT
using InnerHolder = ElementHolder<IndexT>
using TypedIndexContainer = ContType<LookupElementType, InnerHolder>
using LBContFnType = std::function<void()>
using LBContListType = std::list<LBContFnType>
using TypedLBContainer = ContType<LookupElementType, LBContListType>
using FuncApplyType = std::function<void(IndexT const &, CollectionType*)>
using FuncExprType = std::function<bool(IndexT const &)>
using CountType = uint64_t

Public functions

auto exists(IndexT const& idx) -> bool
Check of index exists here.
auto lookup(IndexT const& idx) -> InnerHolder&
Lookup the inner holder for an index.
void insert(IndexT const& idx, InnerHolder&& inner)
Insert a new element.
auto remove(IndexT const& idx) -> VirtualPtrType
Remove an element.
void destroyAll()
Destroy all elements.
auto isDestroyed() const -> bool
Check if collection has been destroyed.
void cleanupExists()
Cleanup deleted elements that were delayed.
void foreach(FuncApplyType fn)
Perform apply action over all collection elements.
auto numElements() const -> TypedIndexContainer::size_type
Count number of elements.
auto numElementsExpr(FuncExprType f) const -> TypedIndexContainer::size_type
Count number of elements that match a expression.
auto group() const -> GroupType
Get current group.
void setGroup(GroupType const& group)
Set a group.
auto useGroup() const -> bool
Whether the group should be used.
void setUseGroup(bool const use_group)
Set whether a group should be used.
auto groupReady() const -> bool
Check if group is ready.
void setGroupReady(bool const ready)
Set if group is ready to be used.
auto groupRoot() const -> NodeType
Get the root of the group.
void setGroupRoot(NodeType const root)
Set the root of the group.
auto addListener(listener::ListenFnType<IndexT> fn) -> int
Add element-specific listener.
void removeListener(int element)
Remove a element listener.
void applyListeners(listener::ElementEventEnum event, IndexT const& idx, NodeType home_node)
Run all listeners.

Function documentation

template<typename IndexT>
bool vt::vrt::collection::Holder<IndexT>::exists(IndexT const& idx)

Check of index exists here.

Parameters
idx in the index
Returns whether it exists

template<typename IndexT>
InnerHolder& vt::vrt::collection::Holder<IndexT>::lookup(IndexT const& idx)

Lookup the inner holder for an index.

Parameters
idx in the index
Returns the inner holder with the actual collection element

template<typename IndexT>
void vt::vrt::collection::Holder<IndexT>::insert(IndexT const& idx, InnerHolder&& inner)

Insert a new element.

Parameters
idx in the index
inner in the inner holder with the collection element unique pointer

template<typename IndexT>
VirtualPtrType vt::vrt::collection::Holder<IndexT>::remove(IndexT const& idx)

Remove an element.

Parameters
idx in the index
Returns unique pointer to element now removed from holder

template<typename IndexT>
bool vt::vrt::collection::Holder<IndexT>::isDestroyed() const

Check if collection has been destroyed.

Returns whether it is destroyed

template<typename IndexT>
void vt::vrt::collection::Holder<IndexT>::cleanupExists()

Cleanup deleted elements that were delayed.

When deleting elements from a handler, it might not be safe to delete them from the holder right away due to a reference/iterator to the element being held while deletion occurs. This method cleans up an elements that are marked as erased.

template<typename IndexT>
void vt::vrt::collection::Holder<IndexT>::foreach(FuncApplyType fn)

Perform apply action over all collection elements.

Parameters
fn in apply function for each element

template<typename IndexT>
TypedIndexContainer::size_type vt::vrt::collection::Holder<IndexT>::numElements() const

Count number of elements.

Returns number of elements

template<typename IndexT>
TypedIndexContainer::size_type vt::vrt::collection::Holder<IndexT>::numElementsExpr(FuncExprType f) const

Count number of elements that match a expression.

Parameters
in apply function that returns membership of expression
Returns number of elements

template<typename IndexT>
GroupType vt::vrt::collection::Holder<IndexT>::group() const

Get current group.

Returns the group ID

template<typename IndexT>
void vt::vrt::collection::Holder<IndexT>::setGroup(GroupType const& group)

Set a group.

Parameters
group in group to set

template<typename IndexT>
bool vt::vrt::collection::Holder<IndexT>::useGroup() const

Whether the group should be used.

Returns whether it should be used

template<typename IndexT>
void vt::vrt::collection::Holder<IndexT>::setUseGroup(bool const use_group)

Set whether a group should be used.

Parameters
use_group in whether it should be used

template<typename IndexT>
bool vt::vrt::collection::Holder<IndexT>::groupReady() const

Check if group is ready.

Returns whether it is ready

template<typename IndexT>
void vt::vrt::collection::Holder<IndexT>::setGroupReady(bool const ready)

Set if group is ready to be used.

Parameters
ready in whether it is ready

template<typename IndexT>
NodeType vt::vrt::collection::Holder<IndexT>::groupRoot() const

Get the root of the group.

Returns the group root

template<typename IndexT>
void vt::vrt::collection::Holder<IndexT>::setGroupRoot(NodeType const root)

Set the root of the group.

Parameters
root in the root

template<typename IndexT>
int vt::vrt::collection::Holder<IndexT>::addListener(listener::ListenFnType<IndexT> fn)

Add element-specific listener.

Parameters
fn in listener function
Returns the registered listener entry ID

template<typename IndexT>
void vt::vrt::collection::Holder<IndexT>::removeListener(int element)

Remove a element listener.

Parameters
element in the entry ID

template<typename IndexT>
void vt::vrt::collection::Holder<IndexT>::applyListeners(listener::ElementEventEnum event, IndexT const& idx, NodeType home_node)

Run all listeners.

Parameters
event in the event type
idx in the index to run on
home_node