STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
List of all members | Public Member Functions | Public Types | Public Attributes | Protected Member Functions | Friends
stapl::vector_view< C, OptionalParams > Class Template Reference

Defines a view that provides the interface of a vector abstract data type. (. More...

Public Member Functions

 vector_view (view_container_type *vcont, domain_type const &dom, map_func_type mfunc=map_function())
 Constructor used to pass ownership of the container to the view. More...
 
 vector_view (view_container_type const &vcont, domain_type const &dom, map_func_type mfunc=map_function())
 Constructor that does not takes ownership over the passed container. More...
 
 vector_view (view_container_type const &vcont, domain_type const &dom, map_func_type mfunc, vector_view const &)
 Constructor that does not takes ownership over the passed container. More...
 
 vector_view (view_container_type *vcont)
 Constructs a view that can reference all the elements of the passed container. The view takes ownership of the container. More...
 
 vector_view (view_container_type &vcont)
 Constructs a view that can reference all the elements of the passed container. More...
 
template<typename ... OtherOptionalParams>
 vector_view (vector_view< C, OtherOptionalParams... > const &other)
 Copy constructor when the passed view is not the most derived view.
 
void add (value_type const &val)
 Insert a new element in the container locally. More...
 
void insert (index_type const &index, value_type const &value)
 Inserts the given value at the position index. More...
 
void push_back (value_type const &value)
 Inserts the given value an the end of the underlying container. More...
 
void pop_back (void)
 Removes the last element in the underlying container. More...
 
void erase (index_type const &index)
 Removes the element at the position index. More...
 
void clear (void)
 Removes all elements from the container.
 
void resize (size_type n)
 Update the underlying container to hold n elements. More...
 
template<typename DistSpecView >
std::enable_if< is_distribution_view< DistSpecView >::value||detail::has_is_composed_dist_spec< DistSpecView >::value >::type redistribute (DistSpecView const &dist_view)
 Update the underlying container to have the distribution specified. More...
 
void flush ()
 Flushes pending update information of the underlying container. More...
 
iterator find (index_type const &index)
 Returns and iterator pointing to the element at position index.
 
reference front (void)
 Returns a reference to the element at the beginning of the underlying container.
 
reference back (void)
 Returns a reference to the element at the end of the underlying container.
 
bool is_valid (void) const
 
view_container_type * get_container (void) const
 
view_container_type & container (void)
 
view_container_type & container (void) const
 
domain_type const & domain (void) const
 
domain_type & domain (void)
 
void set_domain (domain_type const &dom)
 
map_func_type const & mapfunc (void) const
 
size_type size (void) const
 Returns the number of elements referenced for the view.
 
bool empty (void) const
 Returns true if the view does not reference any element.
 
View Read Operations
value_type get_element (index_t const &index) const
 Get the element index from the container. More...
 
future< value_type > get_element_split (index_t const &index) const
 Get the element index from the container. More...
 
template<class Functor >
Functor::result_type apply_get (index_t const &index, Functor f)
 Applies the provided function to the value referenced for the given index and returns the result of the operation. More...
 
template<class Functor >
Functor::result_type apply_get (index_t const &index, Functor f) const
 Applies the provided function to the value referenced for the given index and returns the result of the operation. More...
 
View Write Operations
void set_element (index_t const &index, value_t const &value)
 Set the element index in the container to value value. More...
 
template<class Functor >
void apply_set (index_t const &index, Functor f)
 Applies the provided function to the value referenced for the given index and mutates the element with the resulting value. More...
 
View Subscript Operations
reference_t operator[] (index_t const &index) const
 The bracket operator is the basic access method.
 
reference_t make_reference (index_t const &index) const
 
Sequence Iterator
Warning
Methods in the Sequence Iterator group should only be used inside a work function which is processing a segmented view.
iterator begin (void)
 
const_iterator begin (void) const
 
iterator end (void)
 
const_iterator end (void) const
 
iterator make_iterator (index_t i)
 
index_t next (index_t const &index) const
 Computes the next index based on the given index. More...
 
index_t prev (index_t const &index) const
 Computes the previous index based on the given index. More...
 
index_t advance (index_t const &index, Distance n) const
 Computes the new index after advance n positions from the given index. More...
 
long distance (index_t const &index1, index_t const &index2) const
 
bool less_than (index_t const &index1, index_t const &index2) const
 

Public Types

typedef sequence_op_type::iterator iterator
 
typedef sequence_op_type::const_iterator const_iterator
 
typedef C view_container_type
 
typedef view_traits< vector_view< C, OptionalParams... > >::domain_type domain_type
 
typedef view_traits< vector_view< C, OptionalParams... > >::map_function map_func_type
 
typedef mf_type_helper::index_type index_type
 
typedef mf_type_helper::gid_type gid_type
 
typedef std::size_t size_type
 
using reference_t = typename view_traits< vector_view< C, OptionalParams... > >::reference
 
typedef detail::make_iterator< view_traits< vector_view< C, OptionalParams... > >::derived_type, iteratormake_iterator_t
 

Public Attributes

C * m_ptr
 
sptr_type m_sptr
 

Protected Member Functions

void update_domain (void)
 Updates the view domain. More...
 
C * container_ptr (void) const
 Returns the container's pointer.
 

Friends

template<class T >
class vector_distribution
 

Detailed Description

template<typename C, typename ... OptionalParams>
class stapl::vector_view< C, OptionalParams >

Defines a view that provides the interface of a vector abstract data type. (.

Specialization ensures container transform for variadic based optionals is used.

See also
stapl::list)

Provides the operations that are commonly present in a vector (random access, iteration, insert, push_back, etc.).

Template Parameters
CContainer type.
DomDomain type. By default uses the same domain type provided for the container.
MapFuncMapping function type. (default: identity mapping function)
DerivedType of the most derived class (default: itself)

Constructor & Destructor Documentation

◆ vector_view() [1/5]

template<typename C, typename ... OptionalParams>
stapl::vector_view< C, OptionalParams >::vector_view ( view_container_type *  vcont,
domain_type const &  dom,
map_func_type  mfunc = map_function() 
)

Constructor used to pass ownership of the container to the view.

Parameters
vcontPointer to the container used to forward the operations.
domDomain to be used by the view.
mfuncMapping function to transform view indices to container gids.

◆ vector_view() [2/5]

template<typename C, typename ... OptionalParams>
stapl::vector_view< C, OptionalParams >::vector_view ( view_container_type const &  vcont,
domain_type const &  dom,
map_func_type  mfunc = map_function() 
)

Constructor that does not takes ownership over the passed container.

Parameters
vcontReference to the container used to forward the operations.
domDomain to be used by the view.
mfuncMapping function to transform view indices to container gids.

◆ vector_view() [3/5]

template<typename C, typename ... OptionalParams>
stapl::vector_view< C, OptionalParams >::vector_view ( view_container_type const &  vcont,
domain_type const &  dom,
map_func_type  mfunc,
vector_view< C, OptionalParams > const &   
)

Constructor that does not takes ownership over the passed container.

Parameters
vcontReference to the container used to forward the operations.
domDomain to be used by the view.
mfuncMapping function to transform view indices to container gids.

◆ vector_view() [4/5]

template<typename C, typename ... OptionalParams>
stapl::vector_view< C, OptionalParams >::vector_view ( view_container_type *  vcont)

Constructs a view that can reference all the elements of the passed container. The view takes ownership of the container.

Parameters
vcontPointer to the container used to forward the operations.

◆ vector_view() [5/5]

template<typename C, typename ... OptionalParams>
stapl::vector_view< C, OptionalParams >::vector_view ( view_container_type &  vcont)

Constructs a view that can reference all the elements of the passed container.

Parameters
vcontReference to the container used to forward the operations.

Member Function Documentation

◆ add()

template<typename C, typename ... OptionalParams>
void stapl::vector_view< C, OptionalParams >::add ( value_type const &  val)

Insert a new element in the container locally.

Parameters
valThe value to insert.

◆ insert()

template<typename C, typename ... OptionalParams>
void stapl::vector_view< C, OptionalParams >::insert ( index_type const &  index,
value_type const &  value 
)

Inserts the given value at the position index.

The container will update the view's domain by making an async_rmi to update_domain().

Note
Global synchronization is required after the call in order for all locations to have the fully updated domain.

◆ push_back()

template<typename C, typename ... OptionalParams>
void stapl::vector_view< C, OptionalParams >::push_back ( value_type const &  value)

Inserts the given value an the end of the underlying container.

The container will update the view's domain by making an async_rmi to update_domain().

Note
Global synchronization is required after the call in order for all locations to have the fully updated domain.

◆ pop_back()

template<typename C, typename ... OptionalParams>
void stapl::vector_view< C, OptionalParams >::pop_back ( void  )

Removes the last element in the underlying container.

The container will update the view's domain by making an async_rmi to update_domain().

Note
Global synchronization is required after the call in order for all locations to have the fully updated domain.

◆ erase()

template<typename C, typename ... OptionalParams>
void stapl::vector_view< C, OptionalParams >::erase ( index_type const &  index)

Removes the element at the position index.

The container will update the view's domain by making an async_rmi to update_domain().

Note
Global synchronization is required after the call in order for all locations to have the fully updated domain.

◆ resize()

template<typename C, typename ... OptionalParams>
void stapl::vector_view< C, OptionalParams >::resize ( size_type  n)

Update the underlying container to hold n elements.

Parameters
nThe new size of the container.

◆ redistribute()

template<typename C, typename ... OptionalParams>
template<typename DistSpecView >
std::enable_if< is_distribution_view<DistSpecView>::value || detail::has_is_composed_dist_spec<DistSpecView>::value>::type stapl::vector_view< C, OptionalParams >::redistribute ( DistSpecView const &  dist_view)

Update the underlying container to have the distribution specified.

This function is primarily called when container instances in composed container instances are redistributed.

Parameters
dist_viewSpecification of the desired container distribution, including the distribution of any nested containers in the case of a composed container instance.

◆ flush()

template<typename C, typename ... OptionalParams>
void stapl::vector_view< C, OptionalParams >::flush ( void  )

Flushes pending update information of the underlying container.

This is used in conjunction with add() to insert elements into the container without saturating the communication subsystem with metadata update requests.

◆ update_domain()

template<typename C, typename ... OptionalParams>
void stapl::vector_view< C, OptionalParams >::update_domain ( void  )
protected

Updates the view domain.

This is called after a series of insert or erase calls to refresh the view domain

◆ get_container()

view_container_type* stapl::core_view< C, view_traits< vector_view< C, OptionalParams... > >::domain_type , view_traits< vector_view< C, OptionalParams... > >::map_function >::get_container ( void  ) const
inherited

◆ container()

view_container_type& stapl::core_view< C, view_traits< vector_view< C, OptionalParams... > >::domain_type , view_traits< vector_view< C, OptionalParams... > >::map_function >::container ( void  ) const
inherited

◆ get_element()

template<typename Derived>
value_type stapl::view_operations::read< Derived >::get_element ( index_t const &  index) const
inherited

Get the element index from the container.

Parameters
indexof element to get

◆ get_element_split()

template<typename Derived>
future<value_type> stapl::view_operations::read< Derived >::get_element_split ( index_t const &  index) const
inherited

Get the element index from the container.

Parameters
indexof element to get

◆ apply_get() [1/2]

template<typename Derived>
template<class Functor >
Functor::result_type stapl::view_operations::read< Derived >::apply_get ( index_t const &  index,
Functor  f 
)
inherited

Applies the provided function to the value referenced for the given index and returns the result of the operation.

Parameters
indexof element to apply the function
ffunction to apply
Returns
result of evaluate the function f on the value referenced for the index

◆ apply_get() [2/2]

template<typename Derived>
template<class Functor >
Functor::result_type stapl::view_operations::read< Derived >::apply_get ( index_t const &  index,
Functor  f 
) const
inherited

◆ set_element()

template<typename Derived>
void stapl::view_operations::write< Derived >::set_element ( index_t const &  index,
value_t const &  value 
)
inherited

Set the element index in the container to value value.

Parameters
indexIndex of element to set.
valueNew value to set.

◆ apply_set()

template<typename Derived>
template<class Functor >
void stapl::view_operations::write< Derived >::apply_set ( index_t const &  index,
Functor  f 
)
inherited

Applies the provided function to the value referenced for the given index and mutates the element with the resulting value.

Parameters
indexof element to apply the function
ffunction to apply

◆ next()

index_t stapl::view_operations::sequence< view_traits< vector_view< C, OptionalParams... > >::derived_type , use_default >::next ( index_t const &  index) const
inherited

Computes the next index based on the given index.

Overwriting this method allows produce a different way to traverse the elements referenced by the view.

◆ prev()

index_t stapl::view_operations::sequence< view_traits< vector_view< C, OptionalParams... > >::derived_type , use_default >::prev ( index_t const &  index) const
inherited

Computes the previous index based on the given index.

Overwriting this method allows produce a different way to traverse the elements referenced by the view.

◆ advance()

index_t stapl::view_operations::sequence< view_traits< vector_view< C, OptionalParams... > >::derived_type , use_default >::advance ( index_t const &  index,
Distance  n 
) const
inherited

Computes the new index after advance n positions from the given index.

Overwriting this method allows produce a different way to traverse the elements referenced by the view.


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