DASH  0.3.0
dash::List< ElementType, LocalMemorySpace > Class Template Reference

Usage examples: More...

#include <List.h>

Public Types

typedef ElementType value_type
 Public types as required by DASH list concept. More...
 
typedef dash::default_index_t index_type
 
typedef dash::default_size_t size_type
 
typedef ListRef< ElementType, LocalMemorySpace > view_type
 
typedef LocalListRef< ElementType, LocalMemorySpace > local_type
 
typedef glob_mem_type::local_pointer local_node_iterator
 
typedef glob_mem_type::const_local_pointer const_local_node_iterator
 
typedef index_type difference_type
 Public types as required by STL list concept. More...
 
typedef GlobListIter< value_type, glob_mem_typeiterator
 
typedef GlobListIter< const value_type, glob_mem_typeconst_iterator
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef GlobRef< value_typereference
 
typedef GlobRef< const value_typeconst_reference
 
typedef value_typelocal_reference
 
typedef const value_typeconst_local_reference
 
typedef GlobHeapPtr< value_type, glob_mem_typepointer
 
typedef GlobHeapPtr< const value_type, glob_mem_typeconst_pointer
 
typedef local_node_iterator local_iterator
 
typedef const_local_node_iterator const_local_iterator
 

Public Member Functions

 List (Team &team=dash::Team::Null())
 Default constructor, for delayed allocation. More...
 
 List (size_type nelem=0, Team &team=dash::Team::All())
 Constructor, creates a new constainer instance with the specified initial global container capacity and associated units. More...
 
 List (size_type nelem, size_type nlbuf, Team &team=dash::Team::All())
 Constructor, creates a new constainer instance with the specified initial global container capacity and associated units. More...
 
 ~List ()
 Destructor, deallocates local and global memory acquired by the container instance. More...
 
void push_back (const value_type &element)
 Inserts a new element at the end of the list, after its current last element. More...
 
void pop_back ()
 Removes and destroys the last element in the list, reducing the container size by one. More...
 
reference back ()
 Accesses the last element in the list. More...
 
void push_front (const value_type &value)
 Inserts a new element at the beginning of the list, before its current first element. More...
 
void pop_front ()
 Removes and destroys the first element in the list, reducing the container size by one. More...
 
reference front ()
 Accesses the first element in the list. More...
 
iterator begin () noexcept
 Global pointer to the beginning of the list. More...
 
constexpr const_iterator begin () const noexcept
 Global pointer to the beginning of the list. More...
 
iterator end () noexcept
 Global pointer to the end of the list. More...
 
constexpr const_iterator end () const noexcept
 Global pointer to the end of the list. More...
 
local_iterator lbegin () noexcept
 Native pointer to the first local element in the list. More...
 
constexpr const_local_iterator lbegin () const noexcept
 Native pointer to the first local element in the list. More...
 
local_iterator lend () noexcept
 Native pointer to the end of the list. More...
 
constexpr const_local_iterator lend () const noexcept
 Native pointer to the end of the list. More...
 
constexpr size_type max_size () const noexcept
 Maximum number of elements a list container can hold, e.g. More...
 
constexpr size_type size () const noexcept
 The size of the list. More...
 
void resize (size_t num_elements)
 Resizes the list so its capacity is changed to the given number of elements. More...
 
constexpr size_type capacity () const noexcept
 The number of elements that can be held in currently allocated storage of the list. More...
 
iterator erase (const_iterator position)
 Removes and destroys single element referenced by given iterator from the container, decreasing the container size by 1. More...
 
iterator erase (const_iterator first, const_iterator last)
 Removes and destroys elements in the given range from the container, decreasing the container size by the number of elements removed. More...
 
constexpr Teamteam () const noexcept
 The team containing all units accessing this list. More...
 
constexpr size_type lsize () const noexcept
 The number of elements in the local part of the list. More...
 
constexpr size_type lcapacity () const noexcept
 The capacity of the local part of the list. More...
 
constexpr bool empty () const noexcept
 Whether the list is empty. More...
 
void barrier ()
 Establish a barrier for all units operating on the list, publishing all changes to all units. More...
 
bool allocate (size_type nelem=0, dash::Team &team=dash::Team::All())
 Allocate memory for this container in global memory. More...
 
void deallocate ()
 Free global memory allocated by this container instance. More...
 

Public Attributes

local_type local
 Local proxy object, allows use in range-based for loops. More...
 

Detailed Description

template<typename ElementType, typename LocalMemorySpace = dash::HostSpace>
class dash::List< ElementType, LocalMemorySpace >

Usage examples:

size_t initial_local_capacity = 100; size_t initial_capacity = dash::size() * initial_local_capacity; dash::List<int> list(initial_capacity);

assert(list.size() == 0); assert(list.capacity() == initial_capacity);

list.local.push_back(dash::myid() + 2 + dash::myid() * 3); list.local.push_back(dash::myid() + 3 + dash::myid() * 3); list.local.push_back(dash::myid() + 4 + dash::myid() * 3);

// Logical structure of list for 3 units: // // | unit 0 | unit 1 | unit 2 | // -—|------——|------——|-----——|— // Nil —> 2 –. .—> 5 –. .—> 8 –. // .– 3 <-' | .– 6 <-' | .– 9 <-' // -> 4 -—'-> 7 -—' `-> 10 —> Nil

assert(list.local.size() == 1); assert(list.local.front() == dash::myid() + 1); assert(list.local.back() == dash::myid() + 3);

list.barrier(); assert(list.size() == dash::size() * 3);

if (dash::myid() == 0) { list.push_front(0); list.push_front(1); list.push_back(11); list.push_back(12); list.push_back(13); list.push_back(14); }

// Logical structure of list for 3 units: // // | unit 0 | unit 1 | unit 2 | // -—|------——|------——|-----——|— // Nil —> 0 –. .—> 5 –. .—> 8 –. // .– 1 <-' | .– 6 <-' | .– 9 <-' // -> 2 –. |-> 7 -—' `-> 10 –. // .– 3 <-' | .– 11 <-' // -> 4 -—'-> 12 –. // .– 13 <-' // `-> 14 —> Nil

list.balance();

// Logical structure of list for 3 units: // // | unit 0 | unit 1 | unit 2 | // -—|------——|------——|-----——|— // Nil —> 0 –. .—> 5 –. .—> 10 –. // .– 1 <-' | .– 6 <-' | .– 11 <-' // -> 2 –. |-> 7 –. | `-> 12 –. // .– 3 <-' | .– 8 <-' | .– 13 –' // -> 4 -—'-> 9 -—' `-> 14 —> Nil

A dynamic bi-directional list with support for workload balancing.

Implemented concept:
List Concept

Definition at line 27 of file ListRef.h.

Member Typedef Documentation

◆ difference_type

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
typedef index_type dash::List< ElementType, LocalMemorySpace >::difference_type

Public types as required by STL list concept.

Definition at line 215 of file List.h.

◆ value_type

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
typedef ElementType dash::List< ElementType, LocalMemorySpace >::value_type

Public types as required by DASH list concept.

Definition at line 201 of file List.h.

Constructor & Destructor Documentation

◆ List() [1/3]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
dash::List< ElementType, LocalMemorySpace >::List ( Team team = dash::Team::Null())
inlineexplicit

Default constructor, for delayed allocation.

Sets the associated team to DART_TEAM_NULL for global list instances that are declared before dash::Init().

Definition at line 278 of file List.h.

280  : local(this),
281  _team(&team),
282  _myid(team.myid())
283  {
284  DASH_LOG_TRACE("List() >", "default constructor");
285  }
local_type local
Local proxy object, allows use in range-based for loops.
Definition: List.h:239
constexpr Team & team() const noexcept
The team containing all units accessing this list.
Definition: List.h:538

◆ List() [2/3]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
dash::List< ElementType, LocalMemorySpace >::List ( size_type  nelem = 0,
Team team = dash::Team::All() 
)
inlineexplicit

Constructor, creates a new constainer instance with the specified initial global container capacity and associated units.

Definition at line 291 of file List.h.

References dash::List< ElementType, LocalMemorySpace >::allocate(), dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::allocate(), dash::List< ElementType, LocalMemorySpace >::barrier(), dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::local, dash::Team::size(), and dash::List< ElementType, LocalMemorySpace >::team().

294  : local(this),
295  _team(&team),
296  _myid(team.myid())
297  {
298  DASH_LOG_TRACE("List(nelem,team)", "nelem:", nelem);
299  if (_team->size() > 0) {
300  _local_sizes.allocate(team.size(), dash::BLOCKED, team);
301  _local_sizes.local[0] = 0;
302  }
303  allocate(nelem);
304  barrier();
305  DASH_LOG_TRACE("List(nelem,team) >");
306  }
void barrier()
Establish a barrier for all units operating on the list, publishing all changes to all units...
Definition: List.h:581
bool allocate(size_type nelem=0, dash::Team &team=dash::Team::All())
Allocate memory for this container in global memory.
Definition: List.h:605
size_t size() const
The number of units in this team.
Definition: Team.h:498
local_type local
Local proxy object, allows use in range-based for loops.
Definition: List.h:239
constexpr Team & team() const noexcept
The team containing all units accessing this list.
Definition: List.h:538
bool allocate(size_type nelem, dash::DistributionSpec< 1 > distribution, dash::Team &team=dash::Team::All())
Delayed allocation of global memory using a one-dimensional distribution spec.
Definition: Array.h:1319
local_type local
Local proxy object, allows use in range-based for loops.
Definition: Array.h:732

◆ List() [3/3]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
dash::List< ElementType, LocalMemorySpace >::List ( size_type  nelem,
size_type  nlbuf,
Team team = dash::Team::All() 
)
inline

Constructor, creates a new constainer instance with the specified initial global container capacity and associated units.

Definition at line 312 of file List.h.

References dash::List< ElementType, LocalMemorySpace >::allocate(), dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::allocate(), dash::List< ElementType, LocalMemorySpace >::barrier(), dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::local, dash::Team::size(), and dash::List< ElementType, LocalMemorySpace >::team().

313  : local(this)
314  , _team(&team)
315  , _myid(team.myid())
316  , _local_buffer_size(nlbuf)
317  {
318  DASH_LOG_TRACE("List(nelem,nlbuf,team)",
319  "nelem:", nelem, "nlbuf:", nlbuf);
320  if (_team->size() > 0) {
321  _local_sizes.allocate(team.size(), dash::BLOCKED, team);
322  _local_sizes.local[0] = 0;
323  }
324  allocate(nelem);
325  barrier();
326  DASH_LOG_TRACE("List(nelem,nlbuf,team) >");
327  }
void barrier()
Establish a barrier for all units operating on the list, publishing all changes to all units...
Definition: List.h:581
bool allocate(size_type nelem=0, dash::Team &team=dash::Team::All())
Allocate memory for this container in global memory.
Definition: List.h:605
size_t size() const
The number of units in this team.
Definition: Team.h:498
local_type local
Local proxy object, allows use in range-based for loops.
Definition: List.h:239
constexpr Team & team() const noexcept
The team containing all units accessing this list.
Definition: List.h:538
bool allocate(size_type nelem, dash::DistributionSpec< 1 > distribution, dash::Team &team=dash::Team::All())
Delayed allocation of global memory using a one-dimensional distribution spec.
Definition: Array.h:1319
local_type local
Local proxy object, allows use in range-based for loops.
Definition: Array.h:732

◆ ~List()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
dash::List< ElementType, LocalMemorySpace >::~List ( )
inline

Destructor, deallocates local and global memory acquired by the container instance.

Definition at line 333 of file List.h.

References dash::List< ElementType, LocalMemorySpace >::deallocate().

334  {
335  DASH_LOG_TRACE_VAR("List.~List()", this);
336  deallocate();
337  DASH_LOG_TRACE_VAR("List.~List >", this);
338  }
void deallocate()
Free global memory allocated by this container instance.
Definition: List.h:666

Member Function Documentation

◆ allocate()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
bool dash::List< ElementType, LocalMemorySpace >::allocate ( size_type  nelem = 0,
dash::Team team = dash::Team::All() 
)
inline

Allocate memory for this container in global memory.

Calls implicit barrier on the team associated with the container instance.

Parameters
nelemInitial global capacity of the container.
teamTeam containing all units associated with the container.

Definition at line 605 of file List.h.

References dash::Team::dart_id(), dash::List< ElementType, LocalMemorySpace >::deallocate(), dash::is_initialized(), dash::GlobHeapMem< ElementType, LocalMemorySpace, AllocationPolicy, LocalAlloc >::lbegin(), dash::Team::Null(), dash::Team::register_deallocator(), dash::List< ElementType, LocalMemorySpace >::size(), dash::Team::size(), and dash::List< ElementType, LocalMemorySpace >::team().

Referenced by dash::List< ElementType, LocalMemorySpace >::List().

610  {
611  DASH_LOG_TRACE("List.allocate()");
612  DASH_LOG_TRACE_VAR("List.allocate", nelem);
613  DASH_LOG_TRACE_VAR("List.allocate", _local_buffer_size);
614  if (_team == nullptr || *_team == dash::Team::Null()) {
615  DASH_LOG_TRACE("List.allocate",
616  "initializing with Team::All()");
617  _team = &team;
618  DASH_LOG_TRACE_VAR("List.allocate", team.dart_id());
619  } else {
620  DASH_LOG_TRACE("List.allocate",
621  "initializing with initial team");
622  }
623  DASH_ASSERT_GT(_local_buffer_size, 0, "local buffer size must not be 0");
624  if (nelem < _team->size() * _local_buffer_size) {
625  nelem = _team->size() * _local_buffer_size;
626  }
627  _remote_size = 0;
628  auto lcap = dash::math::div_ceil(nelem, _team->size());
629  // Initialize members:
630  _myid = _team->myid();
631  // Allocate local memory of identical size on every unit:
632  DASH_LOG_TRACE_VAR("List.allocate", lcap);
633 
634  _globmem = new glob_mem_type(lcap, *_team);
635  // Global iterators:
636  _begin = iterator(_globmem, _nil_node);
637  _end = _begin;
638  // Local iterators:
639  _lbegin = _globmem->lbegin();
640  // More efficient than using _globmem->lend as this a second mapping
641  // of the local memory segment:
642  _lend = _lbegin;
643  DASH_LOG_TRACE_VAR("List.allocate", _myid);
644  // Register deallocator of this list instance at the team
645  // instance that has been used to initialized it:
646  _team->register_deallocator(
647  this, std::bind(&List::deallocate, this));
648  // Assure all units are synchronized after allocation, otherwise
649  // other units might start working on the list before allocation
650  // completed at all units:
651  if (dash::is_initialized()) {
652  DASH_LOG_TRACE("List.allocate",
653  "waiting for allocation of all units");
654  _team->barrier();
655  }
656  DASH_LOG_TRACE("List.allocate >", "finished");
657  return true;
658  }
constexpr size_type size() const noexcept
The size of the list.
Definition: List.h:483
void deallocate()
Free global memory allocated by this container instance.
Definition: List.h:666
bool is_initialized()
Check whether DASH has been initialized already.
size_t size() const
The number of units in this team.
Definition: Team.h:498
static Team & Null()
The invariant Team instance representing an undefined team.
Definition: Team.h:229
void register_deallocator(void *object, Deallocator::dealloc_function dealloc)
Register a deallocator function for a team-allocated object.
Definition: Team.h:285
constexpr Team & team() const noexcept
The team containing all units accessing this list.
Definition: List.h:538
local_pointer & lbegin() noexcept
Native pointer of the initial address of the local memory of the unit that initialized this GlobHeapM...
Definition: GlobHeapMem.h:831
dart_team_t dart_id() const
Index of this team relative to global team dash::Team::All().
Definition: Team.h:522

◆ back()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
reference dash::List< ElementType, LocalMemorySpace >::back ( )
inline

Accesses the last element in the list.

Definition at line 368 of file List.h.

369  {
370  }

◆ barrier()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
void dash::List< ElementType, LocalMemorySpace >::barrier ( )
inline

Establish a barrier for all units operating on the list, publishing all changes to all units.

Definition at line 581 of file List.h.

References dash::GlobHeapMem< ElementType, LocalMemorySpace, AllocationPolicy, LocalAlloc >::commit(), and dash::Team::size().

Referenced by dash::List< ElementType, LocalMemorySpace >::deallocate(), and dash::List< ElementType, LocalMemorySpace >::List().

582  {
583  DASH_LOG_TRACE_VAR("List.barrier()", _team);
584  // Apply changes in local memory spaces to global memory space:
585  if (_globmem != nullptr) {
586  _globmem->commit();
587  }
588  // Accumulate local sizes of remote units:
589  _remote_size = 0;
590  for (int u = 0; u < _team->size(); ++u) {
591  if (u != _myid) {
592  size_type local_size_u = _local_sizes[u];
593  _remote_size += local_size_u;
594  }
595  }
596  DASH_LOG_TRACE("List.barrier()", "passed barrier");
597  }
void commit()
Commit changes of local memory region to global memory space.
Definition: GlobHeapMem.h:739
size_t size() const
The number of units in this team.
Definition: Team.h:498

◆ begin() [1/2]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
iterator dash::List< ElementType, LocalMemorySpace >::begin ( )
inlinenoexcept

Global pointer to the beginning of the list.

Definition at line 407 of file List.h.

408  {
409  return _begin;
410  }

◆ begin() [2/2]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
constexpr const_iterator dash::List< ElementType, LocalMemorySpace >::begin ( ) const
inlinenoexcept

Global pointer to the beginning of the list.

Definition at line 415 of file List.h.

416  {
417  return _begin;
418  }

◆ capacity()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
constexpr size_type dash::List< ElementType, LocalMemorySpace >::capacity ( ) const
inlinenoexcept

The number of elements that can be held in currently allocated storage of the list.

Returns
The number of elements in the list.

Definition at line 503 of file List.h.

References dash::GlobHeapMem< ElementType, LocalMemorySpace, AllocationPolicy, LocalAlloc >::size().

504  {
505  return _globmem->size();
506  }
constexpr size_type size() const noexcept
Total number of elements in attached memory space, including size of local unattached memory segments...
Definition: GlobHeapMem.h:422

◆ deallocate()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
void dash::List< ElementType, LocalMemorySpace >::deallocate ( )
inline

Free global memory allocated by this container instance.

Calls implicit barrier on the team associated with the container instance.

Definition at line 666 of file List.h.

References dash::List< ElementType, LocalMemorySpace >::barrier(), dash::is_initialized(), dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::local, and dash::Team::unregister_deallocator().

Referenced by dash::List< ElementType, LocalMemorySpace >::allocate(), and dash::List< ElementType, LocalMemorySpace >::~List().

667  {
668  DASH_LOG_TRACE_VAR("List.deallocate()", this);
669  // Assure all units are synchronized before deallocation, otherwise
670  // other units might still be working on the list:
671  if (dash::is_initialized()) {
672  barrier();
673  }
674  // Remove this function from team deallocator list to avoid
675  // double-free:
676  _team->unregister_deallocator(
677  this, std::bind(&List::deallocate, this));
678  // Deallocate list elements:
679  DASH_LOG_TRACE_VAR("List.deallocate()", _globmem);
680  if (_globmem != nullptr) {
681  delete _globmem;
682  _globmem = nullptr;
683  }
684  _local_sizes.local[0] = 0;
685  _remote_size = 0;
686  DASH_LOG_TRACE_VAR("List.deallocate >", this);
687  }
void barrier()
Establish a barrier for all units operating on the list, publishing all changes to all units...
Definition: List.h:581
void deallocate()
Free global memory allocated by this container instance.
Definition: List.h:666
void unregister_deallocator(void *object, Deallocator::dealloc_function dealloc)
Unregister a deallocator function for a team-allocated object.
Definition: Team.h:300
bool is_initialized()
Check whether DASH has been initialized already.
local_type local
Local proxy object, allows use in range-based for loops.
Definition: Array.h:732

◆ empty()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
constexpr bool dash::List< ElementType, LocalMemorySpace >::empty ( ) const
inlinenoexcept

Whether the list is empty.

Returns
true if size() is 0, otherwise false

Definition at line 572 of file List.h.

References dash::List< ElementType, LocalMemorySpace >::size().

573  {
574  return size() == 0;
575  }
constexpr size_type size() const noexcept
The size of the list.
Definition: List.h:483

◆ end() [1/2]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
iterator dash::List< ElementType, LocalMemorySpace >::end ( )
inlinenoexcept

Global pointer to the end of the list.

Definition at line 423 of file List.h.

424  {
425  return _end;
426  }

◆ end() [2/2]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
constexpr const_iterator dash::List< ElementType, LocalMemorySpace >::end ( ) const
inlinenoexcept

Global pointer to the end of the list.

Definition at line 431 of file List.h.

432  {
433  return _end;
434  }

◆ erase() [1/2]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
iterator dash::List< ElementType, LocalMemorySpace >::erase ( const_iterator  position)
inline

Removes and destroys single element referenced by given iterator from the container, decreasing the container size by 1.

Returns
iterator to the element that follows the last element removed, or end() if the last element was removed.

Definition at line 515 of file List.h.

516  {
517  return _begin;
518  }

◆ erase() [2/2]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
iterator dash::List< ElementType, LocalMemorySpace >::erase ( const_iterator  first,
const_iterator  last 
)
inline

Removes and destroys elements in the given range from the container, decreasing the container size by the number of elements removed.

Returns
iterator to the element that follows the last element removed, or end() if the last element was removed.

Definition at line 527 of file List.h.

528  {
529  return _end;
530  }

◆ front()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
reference dash::List< ElementType, LocalMemorySpace >::front ( )
inline

Accesses the first element in the list.

Definition at line 400 of file List.h.

401  {
402  }

◆ lbegin() [1/2]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
local_iterator dash::List< ElementType, LocalMemorySpace >::lbegin ( )
inlinenoexcept

Native pointer to the first local element in the list.

Definition at line 439 of file List.h.

440  {
441  return _lbegin;
442  }

◆ lbegin() [2/2]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
constexpr const_local_iterator dash::List< ElementType, LocalMemorySpace >::lbegin ( ) const
inlinenoexcept

Native pointer to the first local element in the list.

Definition at line 447 of file List.h.

448  {
449  return _lbegin;
450  }

◆ lcapacity()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
constexpr size_type dash::List< ElementType, LocalMemorySpace >::lcapacity ( ) const
inlinenoexcept

The capacity of the local part of the list.

Returns
The number of allocated elements in the list that are local to the calling unit.

Definition at line 560 of file List.h.

References dash::GlobHeapMem< ElementType, LocalMemorySpace, AllocationPolicy, LocalAlloc >::local_size().

561  {
562  return _globmem != nullptr
563  ? _globmem->local_size()
564  : 0;
565  }
constexpr size_type local_size() const noexcept
Number of elements in local memory space.
Definition: GlobHeapMem.h:430

◆ lend() [1/2]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
local_iterator dash::List< ElementType, LocalMemorySpace >::lend ( )
inlinenoexcept

Native pointer to the end of the list.

Definition at line 455 of file List.h.

456  {
457  return _lend;
458  }

◆ lend() [2/2]

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
constexpr const_local_iterator dash::List< ElementType, LocalMemorySpace >::lend ( ) const
inlinenoexcept

Native pointer to the end of the list.

Definition at line 463 of file List.h.

464  {
465  return _lend;
466  }

◆ lsize()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
constexpr size_type dash::List< ElementType, LocalMemorySpace >::lsize ( ) const
inlinenoexcept

The number of elements in the local part of the list.

Returns
The number of elements in the list that are local to the calling unit.

Definition at line 549 of file List.h.

References dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::local.

Referenced by dash::LocalListRef< ElementType, LocalMemorySpace >::size().

550  {
551  return _local_sizes.local[0];
552  }
local_type local
Local proxy object, allows use in range-based for loops.
Definition: Array.h:732

◆ max_size()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
constexpr size_type dash::List< ElementType, LocalMemorySpace >::max_size ( ) const
inlinenoexcept

Maximum number of elements a list container can hold, e.g.

due to system limitations. The maximum size is not guaranteed.

Definition at line 473 of file List.h.

474  {
475  return std::numeric_limits<index_type>::max();
476  }

◆ pop_back()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
void dash::List< ElementType, LocalMemorySpace >::pop_back ( )
inline

Removes and destroys the last element in the list, reducing the container size by one.

Definition at line 361 of file List.h.

362  {
363  }

◆ pop_front()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
void dash::List< ElementType, LocalMemorySpace >::pop_front ( )
inline

Removes and destroys the first element in the list, reducing the container size by one.

Definition at line 393 of file List.h.

394  {
395  }

◆ push_back()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
void dash::List< ElementType, LocalMemorySpace >::push_back ( const value_type element)
inline

Inserts a new element at the end of the list, after its current last element.

The content of value is copied or moved to the inserted element. Increases the container size by one.

The operation takes immediate effect for the calling unit. For other units, changes will only be visible after the next call of barrier. As one-sided, non-collective allocation on remote units is not possible with most DART communication backends, the new list element is allocated locally and moved to its final position in global memory in barrier.

Definition at line 353 of file List.h.

354  {
355  }

◆ push_front()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
void dash::List< ElementType, LocalMemorySpace >::push_front ( const value_type value)
inline

Inserts a new element at the beginning of the list, before its current first element.

The content of value is copied or moved to the inserted element. Increases the container size by one.

The operation takes immediate effect for the calling unit. For other units, changes will only be visible after the next call of barrier. As one-sided, non-collective allocation on remote units is not possible with most DART communication backends, the new list element is allocated locally and moved to its final position in global memory in barrier.

Definition at line 385 of file List.h.

386  {
387  }

◆ resize()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
void dash::List< ElementType, LocalMemorySpace >::resize ( size_t  num_elements)
inline

Resizes the list so its capacity is changed to the given number of elements.

Elements are removed and destroying elements from the back, if necessary.

Definition at line 493 of file List.h.

494  {
495  }

◆ size()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
constexpr size_type dash::List< ElementType, LocalMemorySpace >::size ( ) const
inlinenoexcept

The size of the list.

Returns
The number of elements in the list.

Definition at line 483 of file List.h.

References dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::local.

Referenced by dash::List< ElementType, LocalMemorySpace >::allocate(), and dash::List< ElementType, LocalMemorySpace >::empty().

484  {
485  return _remote_size + _local_sizes.local[0];
486  }
local_type local
Local proxy object, allows use in range-based for loops.
Definition: Array.h:732

◆ team()

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
constexpr Team& dash::List< ElementType, LocalMemorySpace >::team ( ) const
inlinenoexcept

The team containing all units accessing this list.

Returns
A reference to the Team containing the units associated with the container instance.

Definition at line 538 of file List.h.

Referenced by dash::List< ElementType, LocalMemorySpace >::allocate(), and dash::List< ElementType, LocalMemorySpace >::List().

539  {
540  return *_team;
541  }

Member Data Documentation

◆ local

template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
local_type dash::List< ElementType, LocalMemorySpace >::local

Local proxy object, allows use in range-based for loops.

Definition at line 239 of file List.h.


The documentation for this class was generated from the following files: