#include <xrb_ntuple.hpp>
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 | |
T | m [size] |
The array which stores the n-tuple's components. |
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.
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.
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.
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.
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.
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.
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.
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.
Xrb::NTuple< T, size >::NTuple | ( | T const *const | components | ) | [inline] |
Constructs an n-tuple from an array of component values.
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.
Xrb::NTuple< T, size >::NTuple | ( | NTuple< T, size > const & | source | ) | [inline] |
Copy constructor.
source | The n-tuple to copy. |
Definition at line 133 of file xrb_ntuple.hpp.
Xrb::NTuple< T, size >::~NTuple | ( | ) | [inline] |
void Xrb::NTuple< T, size >::operator= | ( | NTuple< T, size > const & | operand | ) | [inline] |
Assignment operator.
operand | The n-tuple to assign. |
Definition at line 156 of file xrb_ntuple.hpp.
bool Xrb::NTuple< T, size >::operator== | ( | NTuple< T, size > const & | operand | ) | const [inline] |
Equality operator.
operand | The n-tuple to test equality against. |
Definition at line 170 of file xrb_ntuple.hpp.
bool Xrb::NTuple< T, size >::operator!= | ( | NTuple< T, size > const & | operand | ) | const [inline] |
Inequality operator.
operand | The n-tuple to test inequality against. |
Definition at line 186 of file xrb_ntuple.hpp.
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]).
index | The index of the component to reference. |
Definition at line 203 of file xrb_ntuple.hpp.
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]).
index | The index of the component to reference. |
Definition at line 214 of file xrb_ntuple.hpp.
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.
operand | The n-tuple to add to this n-tuple. |
Definition at line 224 of file xrb_ntuple.hpp.
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.
operand | The n-tuple to subtract from this n-tuple. |
Definition at line 234 of file xrb_ntuple.hpp.
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.
operand | The n-tuple to component-wise multiply this n-tuple by. |
Definition at line 246 of file xrb_ntuple.hpp.
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.
operand | The scalar value to multiply this n-tuple by. |
Definition at line 256 of file xrb_ntuple.hpp.
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.
operand | The n-tuple to component-wise divide this n-tuple by. |
Definition at line 269 of file xrb_ntuple.hpp.
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.
operand | The scalar value to divide this n-tuple by. |
Definition at line 280 of file xrb_ntuple.hpp.
NTuple<T, size> Xrb::NTuple< T, size >::operator- | ( | ) | const [inline] |
Unary negation operator.
Definition at line 288 of file xrb_ntuple.hpp.
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.
void Xrb::NTuple< T, size >::FillWith | ( | T const | fill_with | ) | [inline] |
Sets each component in this n-tuple to the specified value.
fill_with | The value to assign to each n-tuple component. |
Definition at line 320 of file xrb_ntuple.hpp.
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
Definition at line 329 of file xrb_ntuple.hpp.
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.
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.
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.
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.
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.
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.
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.
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.
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.
source | The n-tuple to assign. |
Definition at line 410 of file xrb_ntuple.hpp.
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.
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.