KFoundation  v2.1
A Better Foundation Library for C++
 All Classes Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
kfoundation::Tuple Class Reference

Represents a point in n-dimensional space. More...

#include <kfoundation/Tuple.h>

Inheritance diagram for kfoundation::Tuple:
Inheritance graph
[legend]

Public Member Functions

 Tuple ()
 Default constructor, creates a tuple of size 0.
 
 Tuple (kf_int8_t size)
 Constructor, creates a tuple of the given size.
 
 Tuple (const Tuple &other)
 Copy constructor.
 
kf_int8_t getSize () const
 Returns the size of this tuple.
 
kf_int32_tat (const kf_int8_t index)
 Returns the value of the element at the given index.
 
kf_int32_t at (const kf_int8_t index) const
 Returns the value of the element at the given index.
 
void set (const Tuple &other)
 Setter, sets the elements of this tuple to the ones of the given parameter.
 
bool equals (const Tuple &other) const
 Checks if this tuple equals to the given parameter.
 
kf_int32_t sumAll () const
 Returns the sum of all the elements.
 
kf_int64_t productAll () const
 Returns the product of all elements.
 
Tuple max (const Tuple &other) const
 Returns the value of the element with the highest value.
 
Tuple min (const Tuple &other) const
 Returns the value of the element with the lowest value.
 
Tuple negate () const
 Negates all the elements. More...
 
Tuple operator- () const
 Additive inverse operator. More...
 
Tuple operator+ (const Tuple &other) const
 Addition operator. More...
 
Tuple operator- (const Tuple &other) const
 Substraction operator. More...
 
Tuple operator+ (const int n) const
 Adds the given scalar to all elements of this tuple. More...
 
Tuple operator- (const int n) const
 Substracts the given scalar from all elements of this tuple. More...
 
Tuple operator* (const int n) const
 Multiplies all elements of this tuple by the given number. More...
 
Tuple operator* (const Tuple &other) const
 Multiplies all elements of this tuple by the given number. More...
 
Tuple operator/ (const int n) const
 Divides all elements of this tuple by the given number. More...
 
Tuple operator/ (const Tuple &other) const
 Divides each element of this tuple by corresponding element of the given tuple. More...
 
Tuple operator% (const Tuple &other) const
 Calculates remainder of each element of this tuple divided by corresponding element of the given tuple. More...
 
bool operator== (const Tuple &other) const
 Equality operator.
 
void printToStream (Ref< OutputStream > os) const
 Implements compatibility with Streamer interface.
 
- Public Member Functions inherited from kfoundation::Streamer
virtual RefConst< UString > toString () const
 Converts the result of invocation of printToStream(ostream&) to a std::string object.
 

Static Public Member Functions

static Tuple one (kf_int8_t size)
 Returns a unity tuple of the given size.
 
static Tuple zero (kf_int8_t size)
 Returns a zero tuple of the given size.
 

Detailed Description

Represents a point in n-dimensional space.

n can be a number between 0 to 4. Tuple1D, Tuple2D, and Tuple3D are specializations provided for convenience.

Member Function Documentation

Tuple kfoundation::Tuple::negate ( ) const

Negates all the elements.

Returns
A new tuple with each of its element being the inverse of that of this one's.
Tuple kfoundation::Tuple::operator% ( const Tuple other) const

Calculates remainder of each element of this tuple divided by corresponding element of the given tuple.

Parameters
otherThe tuple to divide to.
Returns
The resulting tuple.
Tuple kfoundation::Tuple::operator* ( const int  n) const

Multiplies all elements of this tuple by the given number.

Parameters
otherThe scalar to multiply.
Returns
The resulting tuple.
Tuple kfoundation::Tuple::operator* ( const Tuple other) const

Multiplies all elements of this tuple by the given number.

Parameters
otherThe scalar to multiply.
Returns
The resulting tuple.
Tuple kfoundation::Tuple::operator+ ( const Tuple other) const

Addition operator.

Parameters
otherThe tuple to add to.
Returns
The resulting tuple.
Tuple kfoundation::Tuple::operator+ ( const int  n) const

Adds the given scalar to all elements of this tuple.

Parameters
otherThe scalar to add.
Returns
The resulting tuple.
Tuple kfoundation::Tuple::operator- ( ) const

Additive inverse operator.

Returns
A new tuple with each of its element being the inverse of that of this one's.
Tuple kfoundation::Tuple::operator- ( const Tuple other) const

Substraction operator.

Parameters
otherThe tuple to substract.
Returns
The resulting tuple.
Tuple kfoundation::Tuple::operator- ( const int  n) const

Substracts the given scalar from all elements of this tuple.

Parameters
otherThe scalar to substract.
Returns
The resulting tuple.
Tuple kfoundation::Tuple::operator/ ( const int  n) const

Divides all elements of this tuple by the given number.

Parameters
otherThe scalar to divide to.
Returns
The resulting tuple.
Tuple kfoundation::Tuple::operator/ ( const Tuple other) const

Divides each element of this tuple by corresponding element of the given tuple.

Parameters
otherThe tuple to divide to.
Returns
The resulting tuple.

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