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

removed range class

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.
keep this library to what it was meant to be
a range class is anything but an array
range classes are available elsewhere


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1800
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 5f11efd4
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README,v 1.24 2004-02-10 09:33:03 tforb Exp $
* $Id: README,v 1.25 2005-07-04 13:58:13 tforb Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -72,7 +72,7 @@ namespace aff {
\since December 2002
\date December 2002
\version V1.0
$Id: README,v 1.24 2004-02-10 09:33:03 tforb Exp $
$Id: README,v 1.25 2005-07-04 13:58:13 tforb Exp $
Contents of this page:
- \ref sec_main_aims
......@@ -152,9 +152,6 @@ $Id: README,v 1.24 2004-02-10 09:33:03 tforb Exp $
-# aff::Iterator presented in aff/iterator.h which is an iterator interface
to containers like aff::Array or aff::Series (see example
tests/helpertest.cc).
-# aff::Range presented in aff/lib/range.h which is usefull where ever you
need to deal with numerical ranges (calculate with them, find
the smallest in a set, etc.).
-# aff::subarray presented in aff/subarray.h to conveniently create
subarrays from aff::Array objects (see example
tests/helpertest.cc).
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README.changelog,v 1.53 2005-05-02 09:55:07 tforb Exp $
* $Id: README.changelog,v 1.54 2005-07-04 13:58:14 tforb Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -21,12 +21,16 @@
/*! \page page_changelog ChangeLog (AFF)
$Id: README.changelog,v 1.53 2005-05-02 09:55:07 tforb Exp $
$Id: README.changelog,v 1.54 2005-07-04 13:58:14 tforb Exp $
\sa \ref page_project_status
Major changes in the interface of the library are marked by \b !!.
- \b 04/07/2005 (thof)
- \b !! removed lib/range.h, since the was no kind of array container.
Range classes already exist elsewhere (libtfxx, libpgplotxx).
- \b 28/04/2005 (thof)
- added code for aff::func::histo()
- introduced Tretval to all collector help classes and to collect function
......@@ -221,7 +225,7 @@
/*! \page page_project_status Project status (AFF)
$Id: README.changelog,v 1.53 2005-05-02 09:55:07 tforb Exp $
$Id: README.changelog,v 1.54 2005-07-04 13:58:14 tforb Exp $
\sa \ref page_changelog
......@@ -318,9 +322,6 @@
<TR><TD>libaff/lib/operators.h</TD>
<TD>10/02/2004</TD><TD> </TD><TD>10/02/2004 </TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/range.h</TD>
<TD>13/12/02</TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/rawarfun.h</TD>
<TD>13/12/02</TD><TD> </TD><TD>15/12/02</TD><TD> </TD>
</TR>
......@@ -413,10 +414,6 @@
<TD>23/12/02</TD><TD> </TD><TD>23/12/02</TD>
<TD> </TD>
</TR>
<TR><TD>libaff/tests/rangetest.cc</TD>
<TD> </TD><TD> </TD><TD> </TD>
<TD> </TD>
</TR>
<TR><TD>libaff/tests/reprtest.cc</TD>
<TD>16/12/02</TD><TD> </TD><TD>16/12/02</TD>
<TD>does not check pathological cases</TD>
......
/*! \file range.h
* \brief define an index range
*
* ----------------------------------------------------------------------------
*
* $Id: range.h,v 1.4 2002-12-15 20:48:01 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
* define an index range: aff::Range
*
* \todo
* Explain usage of this file.
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 08/12/2002 V1.0 copied from libcontxx
* - 15/12/2002 V1.1 (thof)
* - no need to place this in namespace prebuilt
*
* ============================================================================
*/
// include guard
#ifndef AFF_RANGE_H_VERSION
#define AFF_RANGE_H_VERSION \
"AFF_RANGE_H V1.1"
#define AFF_RANGE_H_CVSID \
"$Id: range.h,v 1.4 2002-12-15 20:48:01 forbrig Exp $"
namespace aff {
/*! \brief Class to hold and manipulate index ranges.
*
* \param T type of value (usually aff::util::Tsubscript, but may differ)
*
* \todo
* Give more explanations regarding the usefulness of class aff::Range.
*/
template<class T=Tsubscript>
class Range {
public:
//! element type
typedef T Tvalue;
/*-----------------------------------------------------------------*/
//! \name Constructors
//@{
//! empty range
Range(): Mfirst(0), Mlast(0) { }
//! range containing exactly one element
Range(const Tvalue& index): Mfirst(index), Mlast(index) { }
//! set range
Range(const Tvalue& first, const Tvalue& last):
Mfirst(first<last ? first:last),
Mlast(last>first ? last:first) { }
//@}
/*-----------------------------------------------------------------*/
//! \name Access and query functions
//@{
//! access start of range
Tvalue& first() { return Mfirst; }
//! access end of range
Tvalue& last() { return Mlast; }
//! read start of range
const Tvalue& first() const { return Mfirst; }
//! read end of range
const Tvalue& last() const { return Mlast; }
//! is this range inside the other
bool isinside(const Range& other) const
{ return ((Mfirst >= other.first()) && (Mlast <= other.last())); }
//! does this range contain the other
bool contains(const Range& other) const
{ return ((Mfirst <= other.first()) && (Mlast >= other.last())); }
//@}
/*-----------------------------------------------------------------*/
/*! \name Operations modifying the range
*/
//@{
//! shrink to smaller of this and the other
Range& shrink(const Range& other)
{
Mfirst=Mfirst>other.first() ? Mfirst:other.first();
Mlast=Mlast<other.last() ? Mlast:other.last();
return *this;
}
//! expand to larger of this and the other
Range& expand(const Range& other)
{
Mfirst=Mfirst<other.first() ? Mfirst:other.first();
Mlast=Mlast>other.last() ? Mlast:other.last();
return *this;
}
//! shift by n
Range& shift(const Tvalue& n)
{ Mfirst+=n; Mlast+=n; return *this; }
//! shift by n
Range& operator+=(const Tvalue& n)
{ return this->shift(n); }
//! shift by -n
Range& operator-=(const Tvalue& n)
{ return this->shift(-n); }
//@}
/*-----------------------------------------------------------------*/
private:
Tvalue Mfirst; //!< start of range.
Tvalue Mlast; //!< end of range.
}; // class Range
} // namespace aff
#endif // AFF_RANGE_H_VERSION (includeguard)
/* ----- END OF range.h ----- */
/*! \file rangetest.cc
* \brief test range class (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: rangetest.cc,v 1.1 2002-12-06 19:21:08 forbrig Exp $
* \author Thomas Forbriger
* \date 09/06/2002
*
* test range class (implementation)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 09/06/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_RANGETEST_CC_VERSION \
"TF_RANGETEST_CC V1.0 "
#define TF_RANGETEST_CC_CVSID \
"$Id: rangetest.cc,v 1.1 2002-12-06 19:21:08 forbrig Exp $"
#include <rangetest.h>
/* ----- END OF rangetest.cc ----- */
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