1 #ifndef DASH__MAP__UNORDERED_MAP_LOCAL_ITER_H__INCLUDED 2 #define DASH__MAP__UNORDERED_MAP_LOCAL_ITER_H__INCLUDED 6 #include <dash/Types.h> 7 #include <dash/GlobPtr.h> 8 #include <dash/Allocator.h> 10 #include <dash/Onesided.h> 12 #include <dash/map/UnorderedMapLocalIter.h> 14 #include <dash/internal/Logging.h> 16 #include <type_traits> 41 :
public std::iterator<
42 std::random_access_iterator_tag,
43 std::pair<const Key, Mapped>,
44 dash::default_index_t,
45 std::pair<const Key, Mapped> *,
46 std::pair<const Key, Mapped> &>
48 template<
typename K_,
typename M_,
typename H_,
typename P_,
typename LM_>
49 friend std::ostream & dash::operator<<(
61 typedef typename map_t::value_type value_type;
63 typedef typename map_t::index_type index_type;
64 typedef typename map_t::size_type size_type;
70 typedef value_type * pointer;
71 typedef const value_type * const_pointer;
72 typedef value_type & reference;
73 typedef const value_type & const_reference;
93 index_type local_position)
98 DASH_LOG_TRACE(
"UnorderedMapLocalIter(map,lpos)()");
99 DASH_LOG_TRACE_VAR(
"UnorderedMapLocalIter(map,lpos)", _idx);
100 DASH_LOG_TRACE(
"UnorderedMapLocalIter(map,lpos) >");
107 const self_t & other) =
default;
113 const self_t & other) =
default;
123 DASH_LOG_TRACE(
"UnorderedMapLocalIter(nullptr)");
135 inline bool operator==(std::nullptr_t)
const noexcept
140 inline bool operator!=(std::nullptr_t)
const noexcept
160 explicit operator pointer()
const 162 typedef typename map_t::local_node_iterator local_iter_t;
170 return pointer(l_it + static_cast<index_type>(_idx));
180 typedef typename map_t::local_node_iterator local_iter_t;
181 DASH_ASSERT(!_is_nullptr);
186 return *pointer(l_it + static_cast<index_type>(_idx));
197 DASH_LOG_TRACE_VAR(
"UnorderedMapLocalIter.dart_gptr()", _idx);
202 DASH_LOG_TRACE_VAR(
"UnorderedMapLocalIter.dart_gptr >", dart_gptr);
221 local_pos.unit = _myid;
222 local_pos.index = _idx;
229 inline index_type
pos() const noexcept
272 template<
typename K_,
typename M_,
typename H_,
typename P_,
typename A_>
273 inline bool operator==(
276 return (
this == std::addressof(other) || _idx == other._idx);
279 template<
typename K_,
typename M_,
typename H_,
typename P_,
typename A_>
280 inline bool operator!=(
283 return !(*
this == other);
286 self_t & operator+=(index_type offset)
292 self_t & operator-=(index_type offset)
298 self_t operator+(index_type offset)
const 305 self_t operator-(index_type offset)
const 312 inline index_type operator+(
313 const self_t & other)
const 315 return _idx + other._idx;
318 inline index_type operator-(
319 const self_t & other)
const 321 return _idx - other._idx;
324 template<
typename K_,
typename M_,
typename H_,
typename P_,
typename A_>
325 inline bool operator<(
328 return (_idx < other._idx);
331 template<
typename K_,
typename M_,
typename H_,
typename P_,
typename A_>
332 inline bool operator<=(
335 return (_idx <= other._idx);
338 template<
typename K_,
typename M_,
typename H_,
typename P_,
typename A_>
339 inline bool operator>(
342 return (_idx > other._idx);
345 template<
typename K_,
typename M_,
typename H_,
typename P_,
typename A_>
346 inline bool operator>=(
349 return (_idx >= other._idx);
356 void increment(index_type offset)
358 DASH_LOG_TRACE(
"UnorderedMapLocalIter.increment()",
363 DASH_LOG_TRACE(
"UnorderedMapLocalIter.increment >");
369 void decrement(index_type offset)
371 DASH_LOG_TRACE(
"UnorderedMapLocalIter.decrement()",
376 DASH_LOG_TRACE(
"UnorderedMapLocalIter.decrement >");
381 map_t * _map =
nullptr;
383 index_type _idx = -1;
387 bool _is_nullptr =
false;
397 std::ostream & operator<<(
400 Key, Mapped, Hash, Pred, LMemSpace> & it)
402 std::ostringstream ss;
403 ss <<
"dash::UnorderedMapLocalIter<" 404 <<
typeid(Key).name() <<
"," 405 <<
typeid(Mapped).name() <<
">" 407 <<
"unit:" << it._myid <<
", " 408 <<
"lidx:" << it._idx
410 return operator<<(os, ss.str());
415 #endif // DASH__MAP__UNORDERED_MAP_LOCAL_ITER_H__INCLUDED self_t operator++(int)
Postfix increment operator.
internal::default_unsigned_index default_size_t
Unsigned integer type used as default for size values.
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
This class is a simple memory pool which holds allocates elements of size ValueType.
self_t & operator=(const self_t &other)=default
Assignment operator.
self_t & operator=(std::nullptr_t) noexcept
Null-pointer assignment operator.
const glob_mem_type & globmem() const
Reference to instance of DashGlobalMemoryConcept used for underlying memory management of this contai...
self_t & operator--()
Prefix decrement operator.
#define DART_UNDEFINED_TEAM_UNIT_ID
A dart_team_unit_t representing an undefined team-relative unit.
UnorderedMapLocalIter(map_t *map, index_type local_position)
Constructor, creates iterator at specified global position.
self_t & operator++()
Prefix increment operator.
reference operator*() const
Dereference operator.
constexpr bool is_local() const noexcept
Checks whether the element referenced by this global iterator is in the calling unit's local memory...
dart_gptr_t dart_gptr() const
Explicit conversion to dart_gptr_t.
internal::default_signed_index default_index_t
Signed integer type used as default for index values.
#define DART_GPTR_NULL
A NULL global pointer.
A Team instance specifies a subset of all available units.
index_type pos() const noexcept
Position of the iterator in global index space.
pointer at(team_unit_t unit, IndexT local_index)
Resolve the global iterator referencing an element position in a unit's local memory.
DART Global pointer type.
dart_gptr_t dart_gptr() const
Explicit conversion to dart_gptr_t.
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
#define DART_UNDEFINED_UNIT_ID
Undefined unit ID.
UnorderedMapLocalIter()
Default constructor.
UnorderedMapLocalIter(std::nullptr_t)
Null-pointer constructor.
reference operator[](index_type offset)
Random access operator.
local_pointer & lbegin() noexcept
Native pointer of the initial address of the local memory of the unit that initialized this GlobHeapM...
self_t operator--(int)
Postfix decrement operator.
local_index lpos() const noexcept
Unit and local offset at the iterator's position.