stridedstepper.h 3.1 KB
Newer Older
1
2
3
4
5
/*! \file stridedstepper,h.h
 * \brief Stepper class for strided shapes (prototypes)
 * 
 * ----------------------------------------------------------------------------
 * 
6
 * $Id: stridedstepper.h,v 1.2 2002-12-08 22:33:54 forbrig Exp $
7
 * \author Thomas Forbriger
8
 * \since 08/12/2002
9
10
 * 
 * Stepper class for strided shapes (prototypes)
11
12
13
14
 *
 * \note
 * You will not include this header directly. It is included through array.h
 * or binarray.h
15
16
17
18
 * 
 * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
 * 
 * REVISIONS and CHANGES 
19
 *  - 08/12/2002   V1.0   copied from libcontxx
20
21
22
23
24
 * 
 * ============================================================================
 */

// include guard
25
#ifndef AFF_STRIDEDSTEPPER_H_VERSION
26

27
28
29
30
#define AFF_STRIDEDSTEPPER_H_VERSION \
  "AFF_STRIDEDSTEPPER,H_H   V1.0   "
#define AFF_STRIDEDSTEPPER_H_CVSID \
  "$Id: stridedstepper.h,v 1.2 2002-12-08 22:33:54 forbrig Exp $"
31

32
33
34
#include<aff/lib/types.h>
#include<aff/lib/rawarfun.h>
#include<aff/lib/simplearray.h>
35

36
namespace aff {
37

38
#ifdef AFF_PREBUILT
39
40
41
namespace prebuilt {
#endif

42
43
#ifdef AFF_PREBUILT
  using namespace aff::prebuilt::util;
44
#else
45
  using namespace aff::util;
46
47
#endif

48
namespace util {
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

/*! \brief A stepper for all strided shapes.
 *
 */
template<class Shape, Tdim N>
class StridedStepper 
{
  public:
    //! type of stride array
    typedef typename Shape::Tstrides Tstrides;
    //! type of limit arrays
    typedef typename Shape::Tlimits Tindex;
    //! Type of Shape corresponding class
    typedef Shape Tshape;
    //
    //! only non-copy constructor
    StridedStepper(const Tindex& first, const Tstrides& size, 
                   const Tstrides& stride, const Tsubscript& offset);
    //! return current index value for Representation access
    inline
    const Tsubscript& current() const { return(Mcurrent); }
    //! return current index vector for array access
    inline
    const Tindex& index() const { return(Mindex); }
    //! increment offset - return reference to itself
    inline
    StridedStepper& incr();
    //! decrement offset - return reference to itself
    inline
    StridedStepper& decr();
    //! returns true if there are more elements in incr-direction
    inline
    bool more() const;
    //! returns true if there are more elements in decr-direction
    inline
    bool less() const;
    //! set current element index to the first - return reference to itself
    StridedStepper& tofirst();
    //! set current element index to the last - return reference to itself
    StridedStepper& tolast();
  private:
    //! set of smallest index values
    const Tindex& Mfirst;
    //! set of largest index values
    Tindex Mlast;
    //! set of strides
    Tstrides Mstride;
    //! position offset defined by strided shape
    const Tsubscript& Moffset;
    //! current position
    Tsubscript Mcurrent;
    //! current position
    Tindex Mindex;

}; // StridedStepper

105
} // namespace
106

107
#ifdef AFF_PREBUILT
108
109
110
} // namespace prebuilt
#endif

111
} // namespace aff
112

113
#ifndef AFF_NO_DEFINITIONS
114
115
116
117
#include <contxx/shape/stridedstepper_def.h>
#endif


118
#endif // AFF_STRIDEDSTEPPER_H_VERSION (includeguard)
119
120

/* ----- END OF stridedstepper,h.h ----- */