User Documentation
RAVL, Recognition And Vision Library
DEVELOP HOME PAGE CLASS LIST CONTENTS
Ravl - Core - Indexing - IndexC
 

  PUBLIC
IndexC::IndexC(IntT)
IndexC::IndexC(SizeT)
IndexC::IndexC(const IndexC &)
IndexC::IndexC(RealT)
IndexC::V(void) const
IndexC::V(void)
IndexC::IsInRange(SizeT) const
IndexC::operator bool(void) const
IndexC::operator ByteT(void) const
IndexC::operator UByteT(void) const
IndexC::operator SByteT(void) const
IndexC::operator FloatT(void) const
IndexC::operator RealT(void) const
IndexC::operator -(void) const
IndexC::operator ++(void)
IndexC::operator ++(int)
IndexC::operator --(void)
IndexC::operator --(int)
IndexC::operator +(IntT) const
IndexC::operator -(IntT) const
IndexC::operator *(IntT) const
IndexC::operator /(IntT) const
IndexC::operator +=(IntT)
IndexC::operator -=(IntT)
IndexC::operator *=(IntT)
IndexC::operator /=(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 %(IntT) const
IndexC::operator +=(const UIntT)
IndexC::operator -=(const UIntT)
IndexC::operator *=(const UIntT)
IndexC::operator /=(const UIntT)
IndexC::operator +(RealT) const
IndexC::operator -(RealT) const
IndexC::operator *(RealT) const
IndexC::operator /(RealT) const
IndexC::operator +=(RealT)
IndexC::operator -=(RealT)
IndexC::operator *=(RealT)
IndexC::operator /=(RealT)
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 <<(IntT) const
IndexC::operator >>(IntT) const
IndexC::operator ==(IntT) const
IndexC::operator !=(IntT) const
IndexC::operator <(IntT) const
IndexC::operator <=(IntT) const
IndexC::operator >(IntT) const
IndexC::operator >=(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 ==(RealT) const
IndexC::operator !=(RealT) const
IndexC::operator <(RealT) const
IndexC::operator <=(RealT) const
IndexC::operator >(RealT) const
IndexC::operator >=(RealT) 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::Size(void) const

   IndexC   
 
Index class for indexing 1D arrays: an integer class with modified rounding and other operations
 
include "Ravl/Index.hh"
Created:2/1/1996 
User Level:Basic
Library:RavlCore
Example:exIndex.cc
In Scope:RavlN

Comments:
The class IndexC is designed as a replacement for the built-in C int type, in an attempt 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:
Modulo operator:
The modulo operator is always consistent with the divide operator, as per the C and C++ standards. It accordingly always returns a non-negative value.
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:
Variables:
Methods:
IndexC(IntT i = 0)
Creates the index with the value 'i'.

IndexC(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(RealT i)
Creates the index with the value rounded version of 'i'.

Access functions:



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

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

bool 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 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 UByteT() const
Truncates the index value and returns it as UByteT.

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

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

operator RealT() 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 +(IntT i) const
Returns a new index with value of this index added by integer 'i'.

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

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

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

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

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

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

const IndexC & operator /=(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 %(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'.

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

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

RealT operator *(RealT 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.

RealT operator /(RealT 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 +=(RealT i)
Returns this index added by double 'i' cut to integer value.

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

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

const IndexC & operator /=(RealT 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'.

IndexC 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 <<(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 >>(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:



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

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

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

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

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

bool operator >=(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:



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

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

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

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

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

bool 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:



bool operator ==(RealT i) const
Returns true if the value of this index is equal to the integer number 'i'.

bool operator !=(RealT i) const
Returns true if the value of this index is not equal to the integer number 'i'.

bool operator <(RealT i) const
Returns true if the value of this index is smaller than the double number 'i'.

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

bool operator >(RealT i) const
Returns true if the value of this index is greater than the double number 'i'.

bool operator >=(RealT 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:



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

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

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

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

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

bool 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() const
Returns the index whose index value is equal to the absolute value of this index value.

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

IndexC ILog2() 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() const
Generates a randomised hash value for this index.

SizeT Size() const
Returns the number of dimensions indexed.


Maintainer:Radek Marik, Created: 2/1/1996, Documentation by CxxDoc: Tue Aug 13 09:59:02 2002