dune-fem  2.4.1-rc
array_inline.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_ARRAY_INLINE_HH
2 #define DUNE_FEM_ARRAY_INLINE_HH
3 
4 #include "array.hh"
5 
6 namespace Dune
7 {
8 
9  namespace Fem
10  {
11 
12  template< class T >
13  inline void moveBackward ( ArrayInterface< T > &array,
14  const unsigned int oldOffset,
15  const unsigned int newOffset,
16  const unsigned int length )
17  {
18  assert( (oldOffset + length <= array.size())
19  && (newOffset + length <= array.size()) );
20  // note that (unsigned int)(-1) >= length
21  for( unsigned int i = (length - 1); i < length; --i )
22  array[ newOffset + i ] = array[ oldOffset + i ];
23  }
24 
25  template< class T >
26  inline void moveForward ( ArrayInterface< T > &array,
27  const unsigned int oldOffset,
28  const unsigned int newOffset,
29  const unsigned int length )
30  {
31  assert( (oldOffset + length <= array.size())
32  && (newOffset + length <= array.size()) );
33  for( unsigned int i = 0; i < length; ++i )
34  array[ newOffset + i ] = array[ oldOffset + i ];
35  }
36 
37  template< class T >
38  inline void move ( ArrayInterface< T > &array,
39  const unsigned int oldOffset,
40  const unsigned int newOffset,
41  const unsigned int length )
42  {
43  if( oldOffset < newOffset )
44  moveBackward( array, oldOffset, newOffset, length );
45  else
46  moveForward( array, oldOffset, newOffset, length );
47  }
48 
49  } // namespace Fem
50 
51 } // namespace Dune
52 
53 #endif // #ifndef DUNE_FEM_ARRAY_INLINE_HH
void moveForward(ArrayInterface< T > &array, const unsigned int oldOffset, const unsigned int newOffset, const unsigned int length)
Definition: array_inline.hh:26
Definition: coordinate.hh:4
unsigned int size() const
Definition: array.hh:155
void move(ArrayInterface< T > &array, const unsigned int oldOffset, const unsigned int newOffset, const unsigned int length)
Definition: array_inline.hh:38
abstract array interface
Definition: array.hh:23
void moveBackward(ArrayInterface< T > &array, const unsigned int oldOffset, const unsigned int newOffset, const unsigned int length)
Definition: array_inline.hh:13