Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
disarray_store.h
Go to the documentation of this file.
1#ifndef _RHEOLEF_ARRAY_STORE_H
2#define _RHEOLEF_ARRAY_STORE_H
23namespace rheolef {
24//
25// implementation for dense disarray
26//
27template <class OutputRandomIterator, class SetOp, class Size, class IsContainer = std::false_type>
29
30// dense disarray of simple type, i.e. T is a mpi_datatype
31template <class OutputRandomIterator, class SetOp, class Size>
32struct disarray_store<OutputRandomIterator, SetOp, Size, std::false_type> {
33 typedef typename std::iterator_traits<OutputRandomIterator>::value_type T;
34 typedef typename std::pair<Size,T> data_type;
35 void operator()(const std::pair<Size,T>& val) { _op(_x [val.first], val.second); }
36 Size n_new_entry() const { return 0; }
37 disarray_store(OutputRandomIterator x, SetOp op) : _x(x), _op(op) {}
38 OutputRandomIterator _x;
39 SetOp _op;
40};
41// dense disarray of more complex type, i.e. T is a container of mpi_datatype
42template <class OutputRandomIterator, class SetOp, class Size>
43struct disarray_store<OutputRandomIterator, SetOp, Size, std::true_type> {
44 typedef typename std::iterator_traits<OutputRandomIterator>::value_type T;
45 typedef typename T::value_type U;
46 typedef typename std::pair<Size,U> data_type;
47 void operator()(const std::pair<Size,U>& val) {
48 _op (_x [val.first], val.second);
49 }
50 Size n_new_entry() const { return 0; }
51 disarray_store(OutputRandomIterator x, SetOp op) : _x(x), _op(op) {}
52 OutputRandomIterator _x;
53 SetOp _op;
54};
55
56// a simple wrapper, for convenience:
57template <class OutputRandomIterator, class SetOp, class Size, class IsContainer>
58inline
60disarray_make_store(OutputRandomIterator x, SetOp op, Size, IsContainer)
61{
63}
64} // namespace rheolef
65#endif // _RHEOLEF_ARRAY_STORE_H
This file is part of Rheolef.
disarray_store< OutputRandomIterator, SetOp, Size, IsContainer > disarray_make_store(OutputRandomIterator x, SetOp op, Size, IsContainer)
STL namespace.
std::iterator_traits< OutputRandomIterator >::value_type T
std::iterator_traits< OutputRandomIterator >::value_type T