Template Class Set

Nested Relationships

Inheritance Relationships

Base Type

Class Documentation

template <typename T, typename ELEM_COMPARE = MemCmp<T>>
class Set : public shad::AbstractDataStructure<Set<T, ELEM_COMPARE>>

The Set data structure.

SHAD’s set is a distributed, unordered, set.

Warning
obects of type T need to be trivially copiable.
Template Parameters
  • T: type of the entries stored in the set.
  • ELEM_COMPARE: element comparison function; default is MemCmp<T>.

Public Types

template<>
using value_type = T
template<>
using SetT = Set<T, ELEM_COMPARE>
template<>
using LSetT = LocalSet<T, ELEM_COMPARE>
template<>
using ObjectID = typename AbstractDataStructure::ObjectID
template<>
using ShadSetPtr = typename AbstractDataStructure<SetT>::SharedPtr
template<>
using BuffersVector = typename impl::BuffersVector<T, SetT>
template<>
using iterator = set_iterator<Set<T, ELEM_COMPARE>, const T, T>
template<>
using const_iterator = set_iterator<Set<T, ELEM_COMPARE>, const T, T>
template<>
using local_iterator = lset_iterator<LocalSet<T, ELEM_COMPARE>, const T>
template<>
using const_local_iterator = lset_iterator<LocalSet<T, ELEM_COMPARE>, const T>

Public Functions

ObjectID GetGlobalID() const

Create method.

Creates a new set instance.

Return
A shared pointer to the newly created set instance. Getter of the Global Identifier.
Return
The global identifier associated with the set instance.
Parameters
  • numEntries: Expected number of elements.

size_t Size() const

Overall size of the set (number of elements).

Warning
Calling the size method may result in one-to-all communication among localities to retrieve consinstent information.
Return
the size of the set.

std::pair<typename Set<T, ELEM_COMPARE>::iterator, bool> Insert(const T &element)

Insert an element in the set.

Return
a pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.
Parameters
  • element: the element.

void AsyncInsert(rt::Handle &handle, const T &element)

Asynchronously Insert an element in the set.

Warning
Asynchronous operations are guaranteed to have completed only after calling the rt::waitForCompletion(rt::Handle &handle) method.
Parameters
  • handle: Reference to the handle to be used to wait for completion.
  • element: the element.

void BufferedInsert(const T &element)

Buffered Insert method. Inserts an element, using aggregation buffers.

Warning
Insertions are finalized only after calling the WaitForBufferedInsert() method.
Parameters
  • element: The element.

void BufferedAsyncInsert(rt::Handle &handle, const T &element)

Asynchronous Buffered Insert method. Asynchronously inserts an element, using aggregation buffers.

Warning
asynchronous buffered insertions are finalized only after calling the rt::waitForCompletion(rt::Handle &handle) method AND the WaitForBufferedInsert() method, in this order.
Parameters
  • handle: Reference to the handle
  • element: The element.

void WaitForBufferedInsert()

Finalize method for buffered insertions.

void Erase(const T &element)

Remove an element from the set.

Parameters
  • element: the element.

void AsyncErase(rt::Handle &handle, const T &element)

Asynchronously remove an element from the set.

Warning
Asynchronous operations are guaranteed to have completed only after calling the rt::waitForCompletion(rt::Handle &handle) method.
Parameters
  • handle: Reference to the handle to be used to wait for completion.
  • element: the element.

void Clear()

Clear the content of the set.

void Reset(size_t numElements)

Clear the content of the set.

bool Find(const T &element)

Check if the set contains a given element.

Return
true if the element is found, false otherwise.
Parameters
  • element: the element to find.

void AsyncFind(rt::Handle &handle, const T &element, bool *found)

Asynchronously check if the set contains a given element.

Warning
Asynchronous operations are guaranteed to have completed only after calling the rt::waitForCompletion(rt::Handle &handle) method.
Parameters
  • handle: Reference to the handle to be used to wait for completion.
  • element: the element to find.
  • found: the address where to store the result of the operation.

template <typename ApplyFunT, typename... Args>
void ForEachElement(ApplyFunT &&function, Args&... args)

Apply a user-defined function to each element in the set.

Template Parameters
  • ApplyFunT: User-defined function type. The function prototype should be:
    void(const T&, Args&);
    
  • ...Args: Types of the function arguments.
Parameters
  • function: The function to apply.
  • args: The function arguments.

template <typename ApplyFunT, typename... Args>
void AsyncForEachElement(rt::Handle &handle, ApplyFunT &&function, Args&... args)

Asynchronously apply a user-defined function to each element in the set.

Warning
Asynchronous operations are guaranteed to have completed. only after calling the rt::waitForCompletion(rt::Handle &handle) method.
Template Parameters
  • ApplyFunT: User-defined function type. The function prototype should be:
    void(shad::rt::Handle&, const T&, Args&);
    
  • ...Args: Types of the function arguments.
Parameters
  • handle: Reference to the handle. to be used to wait for completion.
  • function: The function to apply.
  • args: The function arguments.

void PrintAllElements()

Print all the entries in the set.

Warning
std::ostream & operator<< must be defined for T.

void BufferEntryInsert(const T &element)
iterator begin()
iterator end()
const_iterator cbegin() const
const_iterator cend() const
const_iterator begin() const
const_iterator end() const
local_iterator local_begin()
local_iterator local_end()
const_local_iterator clocal_begin()
const_local_iterator clocal_end()
std::pair<iterator, bool> insert(const value_type &value)
std::pair<iterator, bool> insert(const_iterator, const value_type &value)
void buffered_async_insert(rt::Handle &h, const value_type &value)
void buffered_async_wait(rt::Handle &h)
void buffered_async_flush()

Protected Functions

Set(ObjectID oid, const size_t numEntries)