Template Class LocalSet¶
- Defined in File local_set.h
Class Documentation¶
-
template <typename T, typename ELEM_COMPARE = MemCmp<T>>
classLocalSet
¶ The LocalSet data structure.
SHAD’s LocalSet is a “local”, unordered, set. LocalSets can be used ONLY on the Locality on which they are created.
- Template Parameters
T
: type of the entries stored in the set.ELEM_COMPARE
: key comparison function; default is MemCmp<T>.
Public Types
-
template<>
usingvalue_type
= T¶
-
template<>
usingiterator
= lset_iterator<LocalSet<T, ELEM_COMPARE>, const T>¶
-
template<>
usingconst_iterator
= lset_iterator<LocalSet<T, ELEM_COMPARE>, const T>¶
Public Functions
-
LocalSet
(const size_t numInitBuckets = 16)¶ Constructor.
- Parameters
numInitBuckets
: initial number of Buckets.
-
size_t
Size
() const¶ Size of the set (number of entries).
- Return
- the size of the set.
-
std::pair<typename LocalSet<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 to insert.
-
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 to insert.
-
void
Erase
(const T &element)¶ Remove an element from the set.
- Parameters
element
: the element to remove.
-
void
AsyncErase
(rt::Handle &handle, const T &element)¶ Asynchronously removen 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 to insert.
-
void
Clear
()¶ Clear the content of the set.
-
void
Reset
(size_t expectedEntries)¶ 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>
voidForEachElement
(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>
voidAsyncForEachElement
(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.
-
iterator
begin
()¶
-
iterator
end
()¶
-
const_iterator
cbegin
()¶
-
const_iterator
cend
()¶
Protected Functions
-
template <typename ApplyFunT, typename SrcT, typename... Args>
voidAsyncForEachNeighbor
(rt::Handle &handle, ApplyFunT &&function, SrcT src, Args... args)¶
-
template <typename ApplyFunT, typename SrcT, typename... Args>
voidForEachNeighbor
(ApplyFunT &&function, SrcT src, Args... args)¶