stridedstepper.h 2.88 KB
Newer Older
1
/*! \file stridedstepper.h
2
3
4
5
 * \brief Stepper class for strided shapes (prototypes)
 * 
 * ----------------------------------------------------------------------------
 * 
6
 * $Id: stridedstepper.h,v 1.3 2002-12-15 20:48:01 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
 *  - 15/12/2002   V1.1   (thof)
 *                        - never place in namespace prebuilt
22
23
24
25
26
 * 
 * ============================================================================
 */

// include guard
27
#ifndef AFF_STRIDEDSTEPPER_H_VERSION
28

29
#define AFF_STRIDEDSTEPPER_H_VERSION \
30
  "AFF_STRIDEDSTEPPER,H_H   V1.1"
31
#define AFF_STRIDEDSTEPPER_H_CVSID \
32
  "$Id: stridedstepper.h,v 1.3 2002-12-15 20:48:01 forbrig Exp $"
33

34
35
36
#include<aff/lib/types.h>
#include<aff/lib/rawarfun.h>
#include<aff/lib/simplearray.h>
37

38
39
namespace aff {
namespace util {
40
41
42
43
44
45
46
47
48
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

/*! \brief A stepper for all strided shapes.
 *
 */
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

95
} // namespace util
96

97
} // namespace aff
98

99
#endif // AFF_STRIDEDSTEPPER_H_VERSION (includeguard)
100

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