Xrb::NTuple< T, size > Class Template Reference

Generalized n-tuple class geared towards high speed efficiency. More...

#include <xrb_ntuple.hpp>

List of all members.

Public Member Functions

 NTuple ()
 Default constructor.
 NTuple (T const component0, T const component1)
 Constructs an n-tuple with the specified ordered pair.
 NTuple (T const component0, T const component1, T const component2)
 Constructs an n-tuple with the specified ordered triplet.
 NTuple (T const component0, T const component1, T const component2, T const component3)
 Constructs an n-tuple with the specified ordered quadruplet.
 NTuple (T const *const components)
 Constructs an n-tuple from an array of component values.
 NTuple (NTuple< T, size > const &source)
 Copy constructor.
 ~NTuple ()
 Destructor.
void operator= (NTuple< T, size > const &operand)
 Assignment operator.
bool operator== (NTuple< T, size > const &operand) const
 Equality operator.
bool operator!= (NTuple< T, size > const &operand) const
 Inequality operator.
T const & operator[] (Uint32 const index) const
 Bracket operator with const qualification.
T & operator[] (Uint32 const index)
 Bracket operator.
void operator+= (NTuple< T, size > const &operand)
 In-place addition operator.
void operator-= (NTuple< T, size > const &operand)
 In-place addition operator.
void operator*= (NTuple< T, size > const &operand)
 In-place multiplication operator.
void operator*= (T const operand)
 In-place multiplication operator.
void operator/= (NTuple< T, size > const &operand)
 In-place division operator.
void operator/= (T const operand)
 In-place division operator.
NTuple< T, size > operator- () const
 Unary negation operator.
template<typename U >
NTuple< U, size > StaticCast () const
 The NTuple equivalent to static_cast.
void FillWith (T const fill_with)
 Sets each component in this n-tuple to the specified value.
void Negate ()
 Sets this n-tuple to the negative of itself.
void SetComponents (T const component0, T const component1)
 Assigns the specified ordered pair to this n-tuple.
void SetComponents (T const component0, T const component1, T const component2)
 Assigns the specified ordered triplet to this n-tuple.
void SetComponents (T const component0, T const component1, T const component2, T const component3)
 Assigns the specified ordered triplet to this n-tuple.
void SetComponents (T const *const components)
 Assigns the specified ordered array of components to the components of this n-tuple.
template<typename U >
void StaticCastAssign (NTuple< U, size > const &source)
 The NTuple equivalent to n-tuple1 = static_cast<T>(n-tuple2).
void Fprint (FILE *const fptr, char const *const component_printf_format, bool const add_newline=true) const
 Prints the size and components of this n-tuple to the given file stream.

Public Attributes

m [size]
 The array which stores the n-tuple's components.


Detailed Description

template<typename T, Uint32 size>
class Xrb::NTuple< T, size >

Generalized n-tuple class geared towards high speed efficiency.

The type must be a regular assignable type (not a type with possibly a vtable, and definitely not a type which requires deep copying to perform assignment). This is because if XRB_NTUPLE_USES_MEMCPY is defined, memcpy() is used to increase efficiency on certain operations. Also, if XRB_NTUPLE_USES_MEMCMP is defined, memcmp() is used on certain operations. The default behavior is to iterate over each component for operations.

Definition at line 44 of file xrb_ntuple.hpp.


Constructor & Destructor Documentation

template<typename T, Uint32 size>
Xrb::NTuple< T, size >::NTuple (  )  [inline]

Default constructor.

Does no initialization for the sake of efficiency.

Definition at line 58 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
Xrb::NTuple< T, size >::NTuple ( T const   component0,
T const   component1 
) [inline]

Constructs an n-tuple with the specified ordered pair.

I gave up trying for partial template specialization (or whatever it's called) to specify the two-parameter constructor for only NTuple<T, 2>, and settled for asserting that size is 2.

Parameters:
component0 The value to assign to the first component (m[0]).
component1 The value to assign to the second component (m[1]).

Definition at line 68 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
Xrb::NTuple< T, size >::NTuple ( T const   component0,
T const   component1,
T const   component2 
) [inline]

Constructs an n-tuple with the specified ordered triplet.

I gave up trying for partial template specialization (or whatever it's called) to specify the two-parameter constructor for only NTuple<T, 3>, and settled for asserting that size is 3.

Parameters:
component0 The value to assign to the first component (m[0]).
component1 The value to assign to the second component (m[1]).
component2 The value to assign to the third component (m[2]).

Definition at line 84 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
Xrb::NTuple< T, size >::NTuple ( T const   component0,
T const   component1,
T const   component2,
T const   component3 
) [inline]

Constructs an n-tuple with the specified ordered quadruplet.

I gave up trying for partial template specialization (or whatever it's called) to specify the two-parameter constructor for only NTuple<T, 4>, and settled for asserting that size is 4.

Parameters:
component0 The value to assign to the first component (m[0]).
component1 The value to assign to the second component (m[1]).
component2 The value to assign to the third component (m[2]).
component3 The value to assign to the fourth component (m[3]).

Definition at line 103 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
Xrb::NTuple< T, size >::NTuple ( T const *const   components  )  [inline]

Constructs an n-tuple from an array of component values.

Parameters:
components The array of ordered components to construct this n-tuple with. Must be at least size elements long.

Definition at line 120 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
Xrb::NTuple< T, size >::NTuple ( NTuple< T, size > const &  source  )  [inline]

Copy constructor.

Parameters:
source The n-tuple to copy.

Definition at line 133 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
Xrb::NTuple< T, size >::~NTuple (  )  [inline]

Destructor.

No cleanup is necessary.

Definition at line 145 of file xrb_ntuple.hpp.


Member Function Documentation

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::operator= ( NTuple< T, size > const &  operand  )  [inline]

Assignment operator.

Parameters:
operand The n-tuple to assign.

Definition at line 156 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
bool Xrb::NTuple< T, size >::operator== ( NTuple< T, size > const &  operand  )  const [inline]

Equality operator.

Parameters:
operand The n-tuple to test equality against.
Returns:
True iff each component of operand is equal to the corresponding component of this n-tuple.

Definition at line 170 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
bool Xrb::NTuple< T, size >::operator!= ( NTuple< T, size > const &  operand  )  const [inline]

Inequality operator.

Parameters:
operand The n-tuple to test inequality against.
Returns:
True iff any component of operand is unequal to the corresponding component of this n-tuple.

Definition at line 186 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
T const& Xrb::NTuple< T, size >::operator[] ( Uint32 const   index  )  const [inline]

Bracket operator with const qualification.

Array index referencing. Emulates the syntax of a normal array, giving a more appealing usage (n-tuple[1] instead of n-tuple.m[1]).

Parameters:
index The index of the component to reference.
Returns:
A const reference to the desired n-tuple component.

Definition at line 203 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
T& Xrb::NTuple< T, size >::operator[] ( Uint32 const   index  )  [inline]

Bracket operator.

Array index referencing. Emulates the syntax of a normal array, giving a more appealing usage (n-tuple[1] instead of n-tuple.m[1]).

Parameters:
index The index of the component to reference.
Returns:
A non-const reference to the desired n-tuple component.

Definition at line 214 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::operator+= ( NTuple< T, size > const &  operand  )  [inline]

In-place addition operator.

Performs vector addition on this and the given n-tuple, storing the result in this n-tuple.

Parameters:
operand The n-tuple to add to this n-tuple.

Definition at line 224 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::operator-= ( NTuple< T, size > const &  operand  )  [inline]

In-place addition operator.

Performs vector subtraction on this and the given n-tuple, storing the result in this n-tuple.

Parameters:
operand The n-tuple to subtract from this n-tuple.

Definition at line 234 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::operator*= ( NTuple< T, size > const &  operand  )  [inline]

In-place multiplication operator.

Performs scalar multiplication of the components of operand on each respective component of this n-tuple, storing the result in this n-tuple.

Parameters:
operand The n-tuple to component-wise multiply this n-tuple by.

Definition at line 246 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::operator*= ( T const   operand  )  [inline]

In-place multiplication operator.

Performs scalar multiplication on this n-tuple by the given scalar storing the result in this n-tuple.

Parameters:
operand The scalar value to multiply this n-tuple by.

Definition at line 256 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::operator/= ( NTuple< T, size > const &  operand  )  [inline]

In-place division operator.

Performs scalar division of the components of this n-tuple by each respective component of operand, storing the result in this n-tuple.

Parameters:
operand The n-tuple to component-wise divide this n-tuple by.
Note:
There is no protection here against dividing by zero.

Definition at line 269 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::operator/= ( T const   operand  )  [inline]

In-place division operator.

Performs scalar division on this n-tuple by the given scalar storing the result in this n-tuple.

Parameters:
operand The scalar value to divide this n-tuple by.
Note:
There is no protection here against dividing by zero.

Definition at line 280 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
NTuple<T, size> Xrb::NTuple< T, size >::operator- (  )  const [inline]

Unary negation operator.

Returns:
The arithmatic negative of this n-tuple.

Definition at line 288 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
template<typename U >
NTuple<U, size> Xrb::NTuple< T, size >::StaticCast (  )  const [inline]

The NTuple equivalent to static_cast.

Performs static_cast on each of this NTuple's components to convert the values to the desired.

Definition at line 305 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::FillWith ( T const   fill_with  )  [inline]

Sets each component in this n-tuple to the specified value.

Parameters:
fill_with The value to assign to each n-tuple component.

Definition at line 320 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::Negate (  )  [inline]

Sets this n-tuple to the negative of itself.

The in-place negation of this n-tuple, or to put another way,

 ms_zero - *this 
(or at least it better equal that!).

Definition at line 329 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::SetComponents ( T const   component0,
T const   component1 
) [inline]

Assigns the specified ordered pair to this n-tuple.

I gave up trying for partial template specialization (or whatever it's called) to specify the two-parameter constructor for only NTuple<T, 2>, and settled for asserting that the size is 2.

Parameters:
component0 The value to assign to the first component (m[0]).
component1 The value to assign to the second component (m[1]).

Definition at line 341 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::SetComponents ( T const   component0,
T const   component1,
T const   component2 
) [inline]

Assigns the specified ordered triplet to this n-tuple.

I gave up trying for partial template specialization (or whatever it's called) to specify the three-parameter constructor for only NTuple<T, 3>, and settled for asserting that the size is 3.

Parameters:
component0 The value to assign to the first component (m[0]).
component1 The value to assign to the second component (m[1]).
component2 The value to assign to the third component (m[2]).

Definition at line 357 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::SetComponents ( T const   component0,
T const   component1,
T const   component2,
T const   component3 
) [inline]

Assigns the specified ordered triplet to this n-tuple.

I gave up trying for partial template specialization (or whatever it's called) to specify the three-parameter constructor for only NTuple<T, 4>, and settled for asserting that the size is 4.

Parameters:
component0 The value to assign to the first component (m[0]).
component1 The value to assign to the second component (m[1]).
component2 The value to assign to the third component (m[2]).
component3 The value to assign to the fourth component (m[3]).

Definition at line 376 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::SetComponents ( T const *const   components  )  [inline]

Assigns the specified ordered array of components to the components of this n-tuple.

Parameters:
components The array of ordered components to assign to this n-tuple. Must be at least size elements long.

Definition at line 394 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
template<typename U >
void Xrb::NTuple< T, size >::StaticCastAssign ( NTuple< U, size > const &  source  )  [inline]

The NTuple equivalent to n-tuple1 = static_cast<T>(n-tuple2).

Performs static_cast on each of the operand n-tuple's components to convert the values.

Parameters:
source The n-tuple to assign.

Definition at line 410 of file xrb_ntuple.hpp.

template<typename T, Uint32 size>
void Xrb::NTuple< T, size >::Fprint ( FILE *const   fptr,
char const *const   component_printf_format,
bool const   add_newline = true 
) const [inline]

Prints the size and components of this n-tuple to the given file stream.

The format of each n-tuple component is specified by component_printf_format, which should be the printf format string for a single n-tuple component. This value must be passed in because the printf format is not known in the general case.

Parameters:
fptr The file stream to print to (e.g. stderr).
component_printf_format The printf format string for a single n-tuple component.
add_newline Indicates if a newline should be printed as the last character (default value is true).

Definition at line 432 of file xrb_ntuple.hpp.


The documentation for this class was generated from the following file:

Hosted by SourceForge.net Logo -- Generated on Fri Aug 21 21:46:39 2009 for XuqRijBuh by doxygen 1.5.8