Developer Documentation
Centre for Vision, Speech & Signal Processing
USER IN NAMESPACE AMMA TREE ROOT AMMA SEARCH AMMA HOME
 

  PUBLIC
IndexC::IndexC(const IntT)
IndexC::IndexC(const SizeT)
IndexC::IndexC(const IndexC &)
IndexC::IndexC(const DoubleT)
IndexC::V(void) const
IndexC::V(void)
IndexC::IsInRange(SizeT) const
IndexC::operator BooleanT(void) const
IndexC::operator bool(void) const
IndexC::operator ByteT(void) const
IndexC::operator CharT(void) const
IndexC::operator SCharT(void) const
IndexC::operator FloatT(void) const
IndexC::operator DoubleT(void) const
IndexC::operator-(void) const
IndexC::operator++(void)
IndexC::operator++(int)
IndexC::operator--(void)
IndexC::operator--(int)
IndexC::operator+(const IntT) const
IndexC::operator-(const IntT) const
IndexC::operator*(const IntT) const
IndexC::operator/(const IntT) const
IndexC::operator+=(const IntT)
IndexC::operator-=(const IntT)
IndexC::operator*=(const IntT)
IndexC::operator/=(const IntT)
IndexC::operator+(const UIntT) const
IndexC::operator-(const UIntT) const
IndexC::operator*(const UIntT) const
IndexC::operator/(const UIntT) const
IndexC::operator%(const UIntT) const
IndexC::operator%(const IntT) const
IndexC::operator+=(const UIntT)
IndexC::operator-=(const UIntT)
IndexC::operator*=(const UIntT)
IndexC::operator/=(const UIntT)
IndexC::operator+(const DoubleT) const
IndexC::operator-(const DoubleT) const
IndexC::operator*(const DoubleT) const
IndexC::operator/(const DoubleT) const
IndexC::operator+=(const DoubleT)
IndexC::operator-=(const DoubleT)
IndexC::operator*=(const DoubleT)
IndexC::operator/=(const DoubleT)
IndexC::operator+(const IndexC &) const
IndexC::operator-(const IndexC &) const
IndexC::operator/(const IndexC &) const
IndexC::operator*(const IndexC &) const
IndexC::operator+=(const IndexC &)
IndexC::operator-=(const IndexC &)
IndexC::operator*=(const IndexC &)
IndexC::operator/=(const IndexC &)
IndexC::operator<<(const IntT) const
IndexC::operator>>(const IntT) const
IndexC::operator==(const IntT) const
IndexC::operator!=(const IntT) const
IndexC::operator<(const IntT) const
IndexC::operator<=(const IntT) const
IndexC::operator>(const IntT) const
IndexC::operator>=(const IntT) const
IndexC::operator==(const UIntT) const
IndexC::operator!=(const UIntT) const
IndexC::operator<(const UIntT) const
IndexC::operator<=(const UIntT) const
IndexC::operator>(const UIntT) const
IndexC::operator>=(const UIntT) const
IndexC::operator==(const DoubleT) const
IndexC::operator!=(const DoubleT) const
IndexC::operator<(const DoubleT) const
IndexC::operator<=(const DoubleT) const
IndexC::operator>(const DoubleT) const
IndexC::operator>=(const DoubleT) const
IndexC::operator==(const IndexC &) const
IndexC::operator!=(const IndexC &) const
IndexC::operator<(const IndexC &) const
IndexC::operator<=(const IndexC &) const
IndexC::operator>(const IndexC &) const
IndexC::operator>=(const IndexC &) const
IndexC::Abs(void) const
IndexC::SetAbs(void)
IndexC::ILog2(void) const
IndexC::Min(const IndexC &) const
IndexC::Max(const IndexC &) const
IndexC::Hash(void) const
IndexC::Dim(void) const
IndexC::GetSize(void) const
IndexC
 
Index class for indexing 1D arrays: an integer class with modified rounding and other operations
 
include "amma/Index.hh"
User Level:Default
Library:MIndex1
Example:exBRefC.cc
Section:Containers.Arrays.1-D Arrays Basic Types Basic Types.Indexing
In Scope:std

Comments:
The class IndexC is designed as a replacement for the built-in C int type, in an atttempt to correct some of the perceived deficiencies of int:

Unsigned integers:
When combining signed and unsigned integers in a binary operation, C always converts the signed integer to unsigned, which can generate surprising results such as:
(unsigned int) 4 / (-2) = 0.
Rounding:
With the int type, rounding is either towards zero (e.g. on conversion from floating point representations), or implementation-dependent (e.g. integer division operations). Where negative numbers are involved, this behaviour is often not what is required, particularly for indexing purposes.
The behaviour of IndexC therefore differs from that of int, to provide more consistent behaviour for indexing purposes, and to improve portability of code.

The major differences between IndexC and int are:

Unsigned integers:
Where relevant, unsigned integers are converted to signed before combining with IndexC.
Rounding:
Rounding is always to the nearest more negative integer. This affects: Thus (IndexC) -5 / 3 yields -2, and (IndexC) -5 % 3 yields 1. With the int type, the results would probably be -1 and -2 respectively.
Remember: IndexC is a class, not a built-in. So: See also the class bugs above.

Bugs:
operator-:
Currently, IndexC::operator-(IndexC) returns an IntT, not (as you might have expected) an IndexC. This can give surprising results.

Enumerated types:
enum anon_enum?7 { dim = 1 } ;
number of indexes

Variables:
IntT v;
The value of the index.

Methods:
IndexC(const IntT i = 0)
Creates the index with the value 'i'.

IndexC(const SizeT s)
Creates the index with the same value as the value of size 's'.

IndexC(const IndexC & i)
Creates the index with the same value as the index 'i' has.

IndexC(const DoubleT i)
Creates the index with the value rounded version of 'i'.

Access functions:



IntT V(void) const
Returns the current value of the index.

IntT & V(void)
Returns the current value of the index.

BooleanT IsInRange(SizeT size) const
True if 0 <= this < size

Conversions:

The obvious conversions from index to integer numbers are missing to avoid automatic conversion of an index expression into integer expression. In this way such a conversion is detected in compilation time and one can decide which type of expression is proper one.

operator BooleanT() const
Returns TRUE if the index value is different from 0.

operator bool() const
Returns TRUE if the index value is different from 0.

operator ByteT() const
Truncates the index value and returns it as ByteT.

operator CharT() const
Truncates the index value and returns it as CharT.

operator SCharT() const
Truncates the index value and returns it as SCharT.

operator FloatT() const
Converts the index value into float representation.

operator DoubleT() const
Converts the index value into double representation.

Arithmetical operations:



IndexC operator-() const
Returns opposite index (unary minus operator).

IndexC & operator++()
The prefix operator increments the index value by 1.

IndexC operator++(int)
The postfix operator increments the index value by 1.

IndexC & operator--()
The prefix operator decrements the index value by 1.

IndexC operator--(int)
The postfix operator decrements the index value by 1.

IndexC operator+(const IntT i) const
Returns a new index with value of this index added by integer 'i'.

IndexC operator-(const IntT i) const
Returns a new index with value of this index subtracted by integer 'i'.

IndexC operator*(const IntT i) const
Returns a new index with value of this index multiplied by integer 'i'.

IndexC operator/(const IntT i) const
Returns a new index with value of this index divided by integer 'i'.

const IndexC & operator+=(const IntT i)
Returns this index added by integer 'i'.

const IndexC & operator-=(const IntT i)
Returns this index subtracted by integer 'i'.

const IndexC & operator*=(const IntT i)
Returns this index multiplied by integer 'i'.

const IndexC & operator/=(const IntT i)
Returns this index divided by integer 'i'.

IndexC operator+(const UIntT i) const
Returns a new index with value of this index added by integer 'i'.

IndexC operator-(const UIntT i) const
Returns a new index with value of this index subtracted by integer 'i'.

IndexC operator*(const UIntT i) const
Returns a new index with value of this index multiplied by integer 'i'.

IndexC operator/(const UIntT i) const
Returns a new index with value of this index divided by integer 'i'.

IndexC operator%(const UIntT i) const
Returns a new index with value of modulo operation between this index and integer 'i'.

IndexC operator%(const IntT i) const
Returns a new index with value of modulo operation between this index and integer 'i'.

const IndexC & operator+=(const UIntT i)
Returns this index added by integer 'i'.

const IndexC & operator-=(const UIntT i)
Returns this index subtracted by integer 'i'.

const IndexC & operator*=(const UIntT i)
Returns this index multiplied by integer 'i'.

const IndexC & operator/=(const UIntT i)
Returns this index divided by integer 'i'.

DoubleT operator+(const DoubleT i) const
Returns a new index with value of this index added by double 'i' cut to integer value.

DoubleT operator-(const DoubleT i) const
Returns a new index with value of this index subtracted by double 'i' cut to integer value.

DoubleT operator*(const DoubleT i) const
Returns a new index with value of this index multiplied by double 'i'. The result is cut to integer value and converted to index value.

DoubleT operator/(const DoubleT i) const
Returns a new index with value of this index divided by double 'i'. The result is cut to integer value and converted to index value.

const IndexC & operator+=(const DoubleT i)
Returns this index added by double 'i' cut to integer value.

const IndexC & operator-=(const DoubleT i)
Returns this index subtracted by double 'i' cut to integer value.

const IndexC & operator*=(const DoubleT i)
Returns this index multiplied by double 'i' with the result converted to index value type.

const IndexC & operator/=(const DoubleT i)
Returns this index divided by double 'i' with the result converted to index value type.

IndexC operator+(const IndexC & i) const
Returns a new index with value of this index added by the value of index 'i'.

IntT operator-(const IndexC & i) const
Returns a value of this index subtracted by the value of index 'i'.

IndexC operator/(const IndexC & i) const
Returns a new index with value of this index divided by the value of index 'i'.

IndexC operator*(const IndexC & i) const
Returns a new index with value of this index multiplied by the value of index 'i'.

const IndexC & operator+=(const IndexC & i)
Returns this index added by index 'i'.

const IndexC & operator-=(const IndexC & i)
Returns this index subtracted by index 'i'.

const IndexC & operator*=(const IndexC & i)
Returns this index multiplied by index 'i'.

const IndexC & operator/=(const IndexC & i)
Returns his index divided by index 'i'.

Modifications of indices:



IndexC operator<<(const IntT i) const
Returns the new index with the value equal to the value of this index shifted 'i' position to the left.

IndexC operator>>(const IntT i) const
Returns the new index with the value equal to the value of this index shifted 'i' position to the right.

Logical operators with integer numbers:



BooleanT operator==(const IntT i) const
Returns TRUE if the value of this index is equal to the integer number 'i'.

BooleanT operator!=(const IntT i) const
Returns TRUE if the value of this index is not equal to the integer number 'i'.

BooleanT operator<(const IntT i) const
Returns TRUE if the value of this index is smaller than the integer number 'i'.

BooleanT operator<=(const IntT i) const
Returns TRUE if the value of this index is smaller than or equal to the integer number 'i'.

BooleanT operator>(const IntT i) const
Returns TRUE if the value of this index is greater than the integer number 'i'.

BooleanT operator>=(const IntT i) const
Returns TRUE if the value of this index is greater than or equal to the integer number 'i'.

Logical operators with unsigned integer numbers:



BooleanT operator==(const UIntT i) const
Returns TRUE if the value of this index is equal to the integer number 'i'.

BooleanT operator!=(const UIntT i) const
Returns TRUE if the value of this index is not equal to the integer number 'i'.

BooleanT operator<(const UIntT i) const
Returns TRUE if the value of this index is smaller than the integer number 'i'.

BooleanT operator<=(const UIntT i) const
Returns TRUE if the value of this index is smaller than or equal to the integer number 'i'.

BooleanT operator>(const UIntT i) const
Returns TRUE if the value of this index is greater than the integer number 'i'.

BooleanT operator>=(const UIntT i) const
Returns TRUE if the value of this index is greater than or equal to the integer number 'i'.

Logical operators with double numbers:



BooleanT operator==(const DoubleT i) const
Returns TRUE if the value of this index is equal to the integer number 'i'.

BooleanT operator!=(const DoubleT i) const
Returns TRUE if the value of this index is not equal to the integer number 'i'.

BooleanT operator<(const DoubleT i) const
Returns TRUE if the value of this index is smaller than the double number 'i'.

BooleanT operator<=(const DoubleT i) const
Returns TRUE if the value of this index is smaller than or equal to the double number 'i'.

BooleanT operator>(const DoubleT i) const
Returns TRUE if the value of this index is greater than the double number 'i'.

BooleanT operator>=(const DoubleT i) const
Returns TRUE if the value of this index is greater than or equal to the double number 'i'.

Logical operators with another index:



BooleanT operator==(const IndexC & i) const
Returns TRUE if the value of this index and index 'i' have got the same value.

BooleanT operator!=(const IndexC & i) const
Returns TRUE if the value of this index and index 'i' are different.

BooleanT operator<(const IndexC & i) const
Returns TRUE if the value of this index is smaller than the value of index 'i'.

BooleanT operator<=(const IndexC & i) const
Returns TRUE if the value of this index is smaller than or equal to the value of index 'i'.

BooleanT operator>(const IndexC & i) const
Returns TRUE if the value of this index is greater than the value of index 'i'.

BooleanT operator>=(const IndexC & i) const
Returns TRUE if the value of this index is greater than or equal to the value of index 'i'.

Miscellaneous functions:



IndexC Abs(void) const
Returns the index whose index value is equal to the absolute value of this index value.

IndexC & SetAbs(void)
Returns this index whose index value is equal to the absolute value of the original index value.

IndexC ILog2(void) const
Returns the index which is logarithm of this index value with base 2.

IndexC Min(const IndexC & i) const
Returns the index with the smaller value.

IndexC Max(const IndexC & i) const
Returns the index with the greater value.

Special member functions:



UIntT Hash(void) const
Generates a randomised hash value for this index.

SizeT Dim(void) const
Returns the number of dimensions indexed.

SizeT GetSize(void) const
This function has no useful meaning


Programmer:Radek Marik, Bill Christmas, Documentation by CxxDoc: Tue Mar 20 10:49:27 2001