Jpp  debug
the software that should make you happy
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
JTOOLS::JArray< 1, T > Class Template Reference

One dimensional array of template objects with fixed length. More...

#include <JArray.hh>

Inheritance diagram for JTOOLS::JArray< 1, T >:
JMATH::JMath< JFirst_t, JSecond_t > JLANG::JEquals< JFirst_t, JSecond_t >

Public Types

typedef const T * const_pointer
 
typedef T * pointer
 
typedef const T * const_iterator
 
typedef T * iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef T & reference
 
typedef const T & const_reference
 
typedef unsigned int size_type
 
typedef JLANG::JClass< T >::argument_type argument_type
 

Public Member Functions

 JArray ()
 Default constructor. More...
 
template<unsigned int M>
 JArray (const JArray< M, T > &array)
 Copy constructor. More...
 
template<unsigned int M>
 JArray (const JArray< M, const T > &array)
 Copy constructor. More...
 
 JArray (const T *p)
 Copy constructor. More...
 
 JArray (const JMultiKey< 1, T > &key)
 Copy constructor. More...
 
 JArray (const JMultiKey< 1, const T > &key)
 Copy constructor. More...
 
 JArray (argument_type value)
 Initialise constructor. More...
 
const_iterator begin () const
 get iterator to begin of data More...
 
const_iterator end () const
 get iterator to end of data More...
 
iterator begin ()
 get iterator to begin of data More...
 
iterator end ()
 get iterator to end of data More...
 
const_reverse_iterator rbegin () const
 get reverse iterator to begin of data More...
 
const_reverse_iterator rend () const
 get reverse iterator to begin of data More...
 
reverse_iterator rbegin ()
 get reverse iterator to begin of data More...
 
reverse_iterator rend ()
 get reverse iterator to end of data More...
 
const_reference operator[] (int index) const
 Get element at given index. More...
 
reference operator[] (int index)
 Get element at given index. More...
 
const_reference at (int index) const
 Get element at given index. More...
 
reference at (int index)
 Get element at given index. More...
 
const_pointer data () const
 Get pointer to data. More...
 
pointer data ()
 Get pointer to data. More...
 
void fill (argument_type value)
 Fill array. More...
 
JArraynegate ()
 Negate array. More...
 
JArrayadd (const JArray &array)
 Add array. More...
 
JArraysub (const JArray &array)
 Subtract array. More...
 
JArraymul (const double factor)
 Scale array. More...
 
JArraydiv (const double factor)
 Scale array. More...
 
bool equals (const JArray< N, T > &array) const
 Check equality. More...
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object. More...
 

Static Public Member Functions

static size_type size ()
 Get size of data. More...
 

Static Public Attributes

static const unsigned int N = 1
 

Protected Attributes

buffer [1]
 

Friends

std::istream & operator>> (std::istream &in, JArray &array)
 Read array from input stream. More...
 
std::ostream & operator<< (std::ostream &out, const JArray &array)
 Write array to output stream. More...
 
JReaderoperator>> (JReader &in, JArray &buffer)
 Read array from input. More...
 
JWriteroperator<< (JWriter &out, const JArray &buffer)
 Write array to output. More...
 

Detailed Description

template<class T>
class JTOOLS::JArray< 1, T >

One dimensional array of template objects with fixed length.

The internal data structure consists of a standard C-array.

Definition at line 653 of file JArray.hh.

Member Typedef Documentation

◆ const_pointer

template<class T >
typedef const T* JTOOLS::JArray< 1, T >::const_pointer

Definition at line 661 of file JArray.hh.

◆ pointer

template<class T >
typedef T* JTOOLS::JArray< 1, T >::pointer

Definition at line 662 of file JArray.hh.

◆ const_iterator

template<class T >
typedef const T* JTOOLS::JArray< 1, T >::const_iterator

Definition at line 663 of file JArray.hh.

◆ iterator

template<class T >
typedef T* JTOOLS::JArray< 1, T >::iterator

Definition at line 664 of file JArray.hh.

◆ const_reverse_iterator

template<class T >
typedef std::reverse_iterator<const_iterator> JTOOLS::JArray< 1, T >::const_reverse_iterator

Definition at line 665 of file JArray.hh.

◆ reverse_iterator

template<class T >
typedef std::reverse_iterator<iterator> JTOOLS::JArray< 1, T >::reverse_iterator

Definition at line 666 of file JArray.hh.

◆ reference

template<class T >
typedef T& JTOOLS::JArray< 1, T >::reference

Definition at line 667 of file JArray.hh.

◆ const_reference

template<class T >
typedef const T& JTOOLS::JArray< 1, T >::const_reference

Definition at line 668 of file JArray.hh.

◆ size_type

template<class T >
typedef unsigned int JTOOLS::JArray< 1, T >::size_type

Definition at line 669 of file JArray.hh.

◆ argument_type

template<class T >
typedef JLANG::JClass<T>::argument_type JTOOLS::JArray< 1, T >::argument_type

Definition at line 670 of file JArray.hh.

Constructor & Destructor Documentation

◆ JArray() [1/7]

template<class T >
JTOOLS::JArray< 1, T >::JArray ( )
inline

Default constructor.

Definition at line 676 of file JArray.hh.

677  {
678  fill(T());
679  }
void fill(argument_type value)
Fill array.
Definition: JArray.hh:858

◆ JArray() [2/7]

template<class T >
template<unsigned int M>
JTOOLS::JArray< 1, T >::JArray ( const JArray< M, T > &  array)
inline

Copy constructor.

Parameters
arrayarray

Definition at line 688 of file JArray.hh.

689  {
690  buffer[0] = array[0];
691  }

◆ JArray() [3/7]

template<class T >
template<unsigned int M>
JTOOLS::JArray< 1, T >::JArray ( const JArray< M, const T > &  array)
inline

Copy constructor.

Parameters
arrayarray

Definition at line 700 of file JArray.hh.

701  {
702  buffer[0] = array[0];
703  }

◆ JArray() [4/7]

template<class T >
JTOOLS::JArray< 1, T >::JArray ( const T *  p)
inline

Copy constructor.

Parameters
ppointer to data

Definition at line 711 of file JArray.hh.

712  {
713  buffer[0] = p[0];
714  }

◆ JArray() [5/7]

template<class T >
JTOOLS::JArray< 1, T >::JArray ( const JMultiKey< 1, T > &  key)
inline

Copy constructor.

Parameters
keymulti-dimensional key

Definition at line 722 of file JArray.hh.

723  {
724  buffer[0] = key.first;
725  }

◆ JArray() [6/7]

template<class T >
JTOOLS::JArray< 1, T >::JArray ( const JMultiKey< 1, const T > &  key)
inline

Copy constructor.

Parameters
keymulti-dimensional key

Definition at line 733 of file JArray.hh.

734  {
735  buffer[0] = key.first;
736  }

◆ JArray() [7/7]

template<class T >
JTOOLS::JArray< 1, T >::JArray ( argument_type  value)
inline

Initialise constructor.

Parameters
valuevalue;

Definition at line 744 of file JArray.hh.

745  {
746  buffer[0] = value;
747  }

Member Function Documentation

◆ begin() [1/2]

template<class T >
const_iterator JTOOLS::JArray< 1, T >::begin ( ) const
inline

get iterator to begin of data

Definition at line 750 of file JArray.hh.

◆ end() [1/2]

template<class T >
const_iterator JTOOLS::JArray< 1, T >::end ( ) const
inline

get iterator to end of data

Definition at line 751 of file JArray.hh.

◆ begin() [2/2]

template<class T >
iterator JTOOLS::JArray< 1, T >::begin ( )
inline

get iterator to begin of data

Definition at line 754 of file JArray.hh.

◆ end() [2/2]

template<class T >
iterator JTOOLS::JArray< 1, T >::end ( )
inline

get iterator to end of data

Definition at line 755 of file JArray.hh.

◆ rbegin() [1/2]

template<class T >
const_reverse_iterator JTOOLS::JArray< 1, T >::rbegin ( ) const
inline

get reverse iterator to begin of data

Definition at line 758 of file JArray.hh.

◆ rend() [1/2]

template<class T >
const_reverse_iterator JTOOLS::JArray< 1, T >::rend ( ) const
inline

get reverse iterator to begin of data

Definition at line 759 of file JArray.hh.

◆ rbegin() [2/2]

template<class T >
reverse_iterator JTOOLS::JArray< 1, T >::rbegin ( )
inline

get reverse iterator to begin of data

Definition at line 762 of file JArray.hh.

◆ rend() [2/2]

template<class T >
reverse_iterator JTOOLS::JArray< 1, T >::rend ( )
inline

get reverse iterator to end of data

Definition at line 763 of file JArray.hh.

◆ operator[]() [1/2]

template<class T >
const_reference JTOOLS::JArray< 1, T >::operator[] ( int  index) const
inline

Get element at given index.

Parameters
indexindex
Returns
element

Definition at line 772 of file JArray.hh.

773  {
774  return buffer[index];
775  }

◆ operator[]() [2/2]

template<class T >
reference JTOOLS::JArray< 1, T >::operator[] ( int  index)
inline

Get element at given index.

Parameters
indexindex
Returns
element

Definition at line 784 of file JArray.hh.

785  {
786  return buffer[index];
787  }

◆ at() [1/2]

template<class T >
const_reference JTOOLS::JArray< 1, T >::at ( int  index) const
inline

Get element at given index.

Parameters
indexindex
Returns
element at index

Definition at line 796 of file JArray.hh.

797  {
798  if (index == 0)
799  return buffer[index];
800  else
801  THROW(JIndexOutOfRange, "invalid index " << 0 << " <= " << index << " < " << N);
802  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
static const unsigned int N
Definition: JArray.hh:659

◆ at() [2/2]

template<class T >
reference JTOOLS::JArray< 1, T >::at ( int  index)
inline

Get element at given index.

Parameters
indexindex
Returns
element at index

Definition at line 811 of file JArray.hh.

812  {
813  if (index == 0)
814  return buffer[index];
815  else
816  THROW(JIndexOutOfRange, "invalid index " << 0 << " <= " << index << " < " << N);
817  }

◆ data() [1/2]

template<class T >
const_pointer JTOOLS::JArray< 1, T >::data ( ) const
inline

Get pointer to data.

Returns
pointer to data

Definition at line 825 of file JArray.hh.

826  {
827  return buffer;
828  }

◆ data() [2/2]

template<class T >
pointer JTOOLS::JArray< 1, T >::data ( )
inline

Get pointer to data.

Returns
pointer to data

Definition at line 836 of file JArray.hh.

837  {
838  return buffer;
839  }

◆ size()

template<class T >
static size_type JTOOLS::JArray< 1, T >::size ( )
inlinestatic

Get size of data.

Returns
size of data

Definition at line 847 of file JArray.hh.

848  {
849  return N;
850  }

◆ fill()

template<class T >
void JTOOLS::JArray< 1, T >::fill ( argument_type  value)
inline

Fill array.

Parameters
valuevalue

Definition at line 858 of file JArray.hh.

859  {
860  buffer[0] = value;
861  }

◆ negate()

template<class T >
JArray& JTOOLS::JArray< 1, T >::negate ( )
inline

Negate array.

Returns
this array

Definition at line 869 of file JArray.hh.

870  {
871  buffer[0] = -buffer[0];
872 
873  return *this;
874  }

◆ add()

template<class T >
JArray& JTOOLS::JArray< 1, T >::add ( const JArray< 1, T > &  array)
inline

Add array.

Parameters
arrayarray
Returns
this array

Definition at line 883 of file JArray.hh.

884  {
885  buffer[0] += array[0];
886 
887  return *this;
888  }

◆ sub()

template<class T >
JArray& JTOOLS::JArray< 1, T >::sub ( const JArray< 1, T > &  array)
inline

Subtract array.

Parameters
arrayarray
Returns
this array

Definition at line 897 of file JArray.hh.

898  {
899  buffer[0] -= array[0];
900 
901  return *this;
902  }

◆ mul() [1/2]

template<class T >
JArray& JTOOLS::JArray< 1, T >::mul ( const double  factor)
inline

Scale array.

Parameters
factormultiplication factor
Returns
this array

Definition at line 911 of file JArray.hh.

912  {
913  buffer[0] *= factor;
914 
915  return *this;
916  }

◆ div()

template<class T >
JArray& JTOOLS::JArray< 1, T >::div ( const double  factor)
inline

Scale array.

Parameters
factordivision factor
Returns
this array

Definition at line 925 of file JArray.hh.

926  {
927  buffer[0] /= factor;
928 
929  return *this;
930  }

◆ equals()

template<class T >
bool JTOOLS::JArray< 1, T >::equals ( const JArray< N, T > &  array) const
inline

Check equality.

Parameters
arrayarray
Returns
true if arrays are equal; else false

Definition at line 939 of file JArray.hh.

940  {
941  return buffer[0] == array[0];
942  }

◆ mul() [2/2]

template<class JFirst_t , class JSecond_t >
JFirst_t& JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t &  object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355  {
356  return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357  }

Friends And Related Function Documentation

◆ operator>> [1/2]

template<class T >
std::istream& operator>> ( std::istream &  in,
JArray< 1, T > &  array 
)
friend

Read array from input stream.

Parameters
ininput stream
arrayarray
Returns
input stream

Definition at line 952 of file JArray.hh.

953  {
954  for (iterator i = array.begin(); i != array.end(); ++i) {
955  in >> *i;
956  }
957 
958  return in;
959  }
const_iterator end() const
get iterator to end of data
Definition: JArray.hh:210
const_iterator begin() const
get iterator to begin of data
Definition: JArray.hh:209

◆ operator<< [1/2]

template<class T >
std::ostream& operator<< ( std::ostream &  out,
const JArray< 1, T > &  array 
)
friend

Write array to output stream.

Parameters
outoutput stream
arrayarray
Returns
output stream

Definition at line 969 of file JArray.hh.

970  {
971  for (const_iterator i = array.begin(); i != array.end(); ++i) {
972  out << ' ' << SCIENTIFIC(12,5) << *i;
973  }
974 
975  return out;
976  }
const T * const_iterator
Definition: JArray.hh:663
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:488

◆ operator>> [2/2]

template<class T >
JReader& operator>> ( JReader in,
JArray< 1, T > &  buffer 
)
friend

Read array from input.

Parameters
inreader
bufferarray
Returns
reader

Definition at line 986 of file JArray.hh.

987  {
988  return in >> buffer[0];
989  }

◆ operator<< [2/2]

template<class T >
JWriter& operator<< ( JWriter out,
const JArray< 1, T > &  buffer 
)
friend

Write array to output.

Parameters
outwriter
bufferarray
Returns
writer

Definition at line 999 of file JArray.hh.

1000  {
1001  return out << buffer[0];
1002  }

Member Data Documentation

◆ N

template<class T >
const unsigned int JTOOLS::JArray< 1, T >::N = 1
static

Definition at line 659 of file JArray.hh.

◆ buffer

template<class T >
T JTOOLS::JArray< 1, T >::buffer[1]
protected

Definition at line 1005 of file JArray.hh.


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