Commit 49a5f6b3 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

introduced series stepper

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1222
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 55364090
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.8 2002-12-18 17:41:32 forbrig Exp $
# $Id: Makefile,v 1.9 2002-12-20 10:18:59 forbrig Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
......@@ -51,8 +51,8 @@ HEADERS=$(shell find . -name \*.h)
# in the binary version of the library
# (see below for the configuration of a preinstantiated version of template
# code)
SRC=lib/error.cc dump.cc lib/strided.cc lib/stridedstepper.cc
#SRC=lib/error.cc dump.cc lib/strided.cc
SRC=lib/error.cc dump.cc lib/strided.cc lib/stridedstepper.cc \
lib/seriesstepper.cc
# test programs are placed in a subdirectory
TESTS=$(wildcard tests/*.cc)
# whereever we find a README, we will use it
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README.changelog,v 1.11 2002-12-19 18:37:47 forbrig Exp $
* $Id: README.changelog,v 1.12 2002-12-20 10:18:59 forbrig Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -20,12 +20,16 @@
/*! \page page_changelog ChangeLog (AFF)
$Id: README.changelog,v 1.11 2002-12-19 18:37:47 forbrig Exp $
$Id: README.changelog,v 1.12 2002-12-20 10:18:59 forbrig Exp $
\sa \ref page_project_status
Major changes in the interface of the library are marked by \b !!.
- \b 20/12/2002 (thof)
- introduced aff/lib/seriesstepper.h and aff/lib/seriesstepper.cc
which define aff::util::SeriesStepper
- \b 19/12/2002 (thof)
- \b !! aff::Array provides access to base classes through access
functions and not through conversion operators.
......@@ -60,16 +64,16 @@
/*! \page page_project_status Project status (AFF)
$Id: README.changelog,v 1.11 2002-12-19 18:37:47 forbrig Exp $
$Id: README.changelog,v 1.12 2002-12-20 10:18:59 forbrig Exp $
\sa \ref page_changelog
<TABLE>
<TR><TD><B>Filename</B></TD>
<TD><B>code is complete</B></TD>
<TD><B>docu is complete</B></TD>
<TD><B>documentation is complete</B></TD>
<TD><B>code is tested</B></TD>
<TD><B>deserves revision</B></TD>
<TD><B>revision is required</B></TD>
<TR><TD>libaff/README</TD>
<TD>has no code</TD><TD> </TD><TD>has no code</TD><TD> </TD>
</TR>
......@@ -137,6 +141,12 @@
<TR><TD>libaff/lib/strided.h</TD>
<TD>13/12/02</TD><TD> </TD><TD>18/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/seriesstepper.cc</TD>
<TD>20/12/02</TD><TD>20/12/02</TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/seriesstepper.h</TD>
<TD>20/12/02</TD><TD>20/12/02</TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/stridedstepper.cc</TD>
<TD>18/12/02</TD><TD> </TD><TD>18/12/02</TD><TD> </TD>
</TR>
......
/*! \file seriesstepper.cc
* \brief a stepper class for aff::Series (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: seriesstepper.cc,v 1.1 2002-12-20 10:18:42 forbrig Exp $
* \author Thomas Forbriger
* \date 20/12/2002
*
* a stepper class for aff::Series (implementation)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 20/12/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define AFF_SERIESSTEPPER_CC_VERSION \
"AFF_SERIESSTEPPER_CC V1.0"
#define AFF_SERIESSTEPPER_CC_CVSID \
"$Id: seriesstepper.cc,v 1.1 2002-12-20 10:18:42 forbrig Exp $"
#include <aff/lib/seriesstepper.h>
namespace aff {
namespace util {
//! next element
SeriesStepper& SeriesStepper::incr()
{
if (++Mcurrent>Mlast_offset)
{
Mcurrent=Mfirst_offset;
Mvalid=false;
}
return(*this);
}
/*----------------------------------------------------------------------*/
//! previous element
SeriesStepper& SeriesStepper::decr()
{
if (--Mcurrent<Mfirst_offset)
{
Mcurrent=Mlast_offset;
Mvalid=false;
}
return(*this);
}
/*----------------------------------------------------------------------*/
//! skip to first
SeriesStepper& SeriesStepper::tofirst()
{
Mcurrent=Mfirst_offset;
Mvalid=true;
return(*this);
}
/*----------------------------------------------------------------------*/
//! skip to last
SeriesStepper& SeriesStepper::tolast()
{
Mcurrent=Mlast_offset;
Mvalid=true;
return(*this);
}
} // namespace util
} // namespace aff
/* ----- END OF seriesstepper.cc ----- */
/*! \file seriesstepper.h
* \brief a stepper class for aff::Series (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: seriesstepper.h,v 1.1 2002-12-20 10:18:43 forbrig Exp $
* \author Thomas Forbriger
* \date 20/12/2002
*
* a stepper class for aff::Series (prototypes)
*
* \note
* This file is automatically included through aff/series.h
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 20/12/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef AFF_SERIESSTEPPER_H_VERSION
#define AFF_SERIESSTEPPER_H_VERSION \
"AFF_SERIESSTEPPER_H V1.0"
#define AFF_SERIESSTEPPER_H_CVSID \
"$Id: seriesstepper.h,v 1.1 2002-12-20 10:18:43 forbrig Exp $"
#include<aff/lib/types.h>
namespace aff {
namespace util {
/*! \brief A stepper for aff::Series
*
* If we provide a stepper class, The aff::Iterator template can work with
* the aff::Series.
*
* This class cycles through the offset range of an aff::Series. It is used
* internally within aff::Series::operator=() for value assignment. And it
* is used within the aff::Iterator and aff::Browser classes. You normally
* will not use it directly.
*/
class SeriesStepper
{
//! only non-copy constructor
SeriesStepper(const Tsubscript& first,
const Tsubscript& last,
const Tsize& base):
Mfirst_offset(first-base), Mlast_offset(last-base),
Mbase(base), Mcurrent(first-base), Mvalid(true) { }
//! return current index value for Representation access
const Tsubscript& current() const { return(Mcurrent); }
//! return current index vector for array access
Tsubscript index() const { return(Mcurrent+Mbase); }
//! increment offset - return reference to itself
SeriesStepper& incr();
//! decrement offset - return reference to itself
SeriesStepper& decr();
//! returns true if there are more elements in incr-direction
bool more() const
{ return(Mcurrent<Mlast_offset); }
//! returns true if there are more elements in decr-direction
bool less() const
{ return(Mcurrent>Mfirst_offset); }
//! valid if not passed end or beginning
const bool& valid() const
{ return(Mvalid); }
//! set current element index to the first - return reference to itself
SeriesStepper& tofirst();
//! set current element index to the last - return reference to itself
SeriesStepper& tolast();
private:
//! store current bounds to reduce execution time
Tsubscript Mfirst_offset, Mlast_offset;
//! hold reference to shape
Tsize Mbase;
//! hold current position offset to memory
Tsubscript Mcurrent;
//! true while not passed start or end
bool Mvalid;
}; // class SeriesStepper
} // namespace util
} // namespace aff
#endif // AFF_SERIESSTEPPER_H_VERSION (includeguard)
/* ----- END OF seriesstepper.h ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: stridedstepper.h,v 1.5 2002-12-19 18:30:06 forbrig Exp $
* $Id: stridedstepper.h,v 1.6 2002-12-20 10:18:43 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -35,7 +35,7 @@
#define AFF_STRIDEDSTEPPER_H_VERSION \
"AFF_STRIDEDSTEPPER,H_H V1.3"
#define AFF_STRIDEDSTEPPER_H_CVSID \
"$Id: stridedstepper.h,v 1.5 2002-12-19 18:30:06 forbrig Exp $"
"$Id: stridedstepper.h,v 1.6 2002-12-20 10:18:43 forbrig Exp $"
#include<aff/lib/strided.h>
......@@ -76,7 +76,7 @@ class StridedStepper
//! returns true if there are more elements in decr-direction
bool less() const
{ return(Mcurrent>Mfirst_offset); }
//! valid if not passed and or beginning
//! valid if not passed end or beginning
const bool& valid() const
{ return(Mvalid); }
//! set current element index to the first - return reference to itself
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment