Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
template<unsigned int M>
 JArray (const JArray< M, T > &array)
 Copy constructor.
 
template<unsigned int M>
 JArray (const JArray< M, const T > &array)
 Copy constructor.
 
 JArray (const T *p)
 Copy constructor.
 
 JArray (const JMultiKey< 1, T > &key)
 Copy constructor.
 
 JArray (const JMultiKey< 1, const T > &key)
 Copy constructor.
 
 JArray (argument_type value)
 Initialise constructor.
 
 operator JMultiKey< N, T > () const
 Type conversion operator.
 
const_iterator begin () const
 get iterator to begin of data
 
const_iterator end () const
 get iterator to end of data
 
iterator begin ()
 get iterator to begin of data
 
iterator end ()
 get iterator to end of data
 
const_reverse_iterator rbegin () const
 get reverse iterator to begin of data
 
const_reverse_iterator rend () const
 get reverse iterator to begin of data
 
reverse_iterator rbegin ()
 get reverse iterator to begin of data
 
reverse_iterator rend ()
 get reverse iterator to end of data
 
const_reference operator[] (int index) const
 Get element at given index.
 
reference operator[] (int index)
 Get element at given index.
 
const_reference at (int index) const
 Get element at given index.
 
reference at (int index)
 Get element at given index.
 
const_pointer data () const
 Get pointer to data.
 
pointer data ()
 Get pointer to data.
 
void fill (argument_type value)
 Fill array.
 
JArraynegate ()
 Negate array.
 
JArrayadd (const JArray &array)
 Add array.
 
JArraysub (const JArray &array)
 Subtract array.
 
JArraymul (const double factor)
 Scale array.
 
JArraydiv (const double factor)
 Scale array.
 
bool equals (const JArray< N, T > &array) const
 Check equality.
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object.
 

Static Public Member Functions

static size_type size ()
 Get size of data.
 

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.
 
std::ostream & operator<< (std::ostream &out, const JArray &array)
 Write array to output stream.
 
JReaderoperator>> (JReader &in, JArray &buffer)
 Read array from input.
 
JWriteroperator<< (JWriter &out, const JArray &buffer)
 Write array to output.
 

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 664 of file JArray.hh.

Member Typedef Documentation

◆ const_pointer

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

Definition at line 672 of file JArray.hh.

◆ pointer

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

Definition at line 673 of file JArray.hh.

◆ const_iterator

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

Definition at line 674 of file JArray.hh.

◆ iterator

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

Definition at line 675 of file JArray.hh.

◆ const_reverse_iterator

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

Definition at line 676 of file JArray.hh.

◆ reverse_iterator

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

Definition at line 677 of file JArray.hh.

◆ reference

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

Definition at line 678 of file JArray.hh.

◆ const_reference

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

Definition at line 679 of file JArray.hh.

◆ size_type

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

Definition at line 680 of file JArray.hh.

◆ argument_type

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

Definition at line 681 of file JArray.hh.

Constructor & Destructor Documentation

◆ JArray() [1/7]

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

Default constructor.

Definition at line 687 of file JArray.hh.

688 {
689 fill(T());
690 }
void fill(argument_type value)
Fill array.
Definition JArray.hh:880

◆ 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 699 of file JArray.hh.

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

◆ 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 711 of file JArray.hh.

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

◆ JArray() [4/7]

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

Copy constructor.

Parameters
ppointer to data

Definition at line 722 of file JArray.hh.

723 {
724 buffer[0] = p[0];
725 }

◆ 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 733 of file JArray.hh.

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

◆ 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 744 of file JArray.hh.

745 {
746 buffer[0] = key.first;
747 }

◆ JArray() [7/7]

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

Initialise constructor.

Parameters
valuevalue;

Definition at line 755 of file JArray.hh.

756 {
757 buffer[0] = value;
758 }

Member Function Documentation

◆ operator JMultiKey< N, T >()

template<class T >
JTOOLS::JArray< 1, T >::operator JMultiKey< N, T > ( ) const
inline

Type conversion operator.

Returns
multi-key

Definition at line 766 of file JArray.hh.

767 {
768 return JMultiKey<N, T>(buffer[0]);
769 }

◆ begin() [1/2]

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

get iterator to begin of data

Definition at line 772 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 773 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 776 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 777 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 780 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 781 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 784 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 785 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 794 of file JArray.hh.

795 {
796 return buffer[index];
797 }

◆ 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 806 of file JArray.hh.

807 {
808 return buffer[index];
809 }

◆ 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 818 of file JArray.hh.

819 {
820 if (index == 0)
821 return buffer[index];
822 else
823 THROW(JIndexOutOfRange, "invalid index " << 0 << " <= " << index << " < " << N);
824 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
static const unsigned int N
Definition JArray.hh:670

◆ 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 833 of file JArray.hh.

834 {
835 if (index == 0)
836 return buffer[index];
837 else
838 THROW(JIndexOutOfRange, "invalid index " << 0 << " <= " << index << " < " << N);
839 }

◆ 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 847 of file JArray.hh.

848 {
849 return buffer;
850 }

◆ data() [2/2]

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

Get pointer to data.

Returns
pointer to data

Definition at line 858 of file JArray.hh.

859 {
860 return buffer;
861 }

◆ size()

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

Get size of data.

Returns
size of data

Definition at line 869 of file JArray.hh.

870 {
871 return N;
872 }

◆ fill()

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

Fill array.

Parameters
valuevalue

Definition at line 880 of file JArray.hh.

881 {
882 buffer[0] = value;
883 }

◆ negate()

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

Negate array.

Returns
this array

Definition at line 891 of file JArray.hh.

892 {
893 buffer[0] = -buffer[0];
894
895 return *this;
896 }

◆ 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 905 of file JArray.hh.

906 {
907 buffer[0] += array[0];
908
909 return *this;
910 }

◆ 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 919 of file JArray.hh.

920 {
921 buffer[0] -= array[0];
922
923 return *this;
924 }

◆ 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 933 of file JArray.hh.

934 {
935 buffer[0] *= factor;
936
937 return *this;
938 }

◆ 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 947 of file JArray.hh.

948 {
949 buffer[0] /= factor;
950
951 return *this;
952 }

◆ 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 961 of file JArray.hh.

962 {
963 return buffer[0] == array[0];
964 }

◆ 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 Symbol 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 974 of file JArray.hh.

975 {
976 for (iterator i = array.begin(); i != array.end(); ++i) {
977 in >> *i;
978 }
979
980 return in;
981 }

◆ 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 991 of file JArray.hh.

992 {
993 for (const_iterator i = array.begin(); i != array.end(); ++i) {
994 out << ' ' << SCIENTIFIC(12,5) << *i;
995 }
996
997 return out;
998 }
const T * const_iterator
Definition JArray.hh:674
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 1008 of file JArray.hh.

1009 {
1010 return in >> buffer[0];
1011 }

◆ 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 1021 of file JArray.hh.

1022 {
1023 return out << buffer[0];
1024 }

Member Data Documentation

◆ N

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

Definition at line 670 of file JArray.hh.

◆ buffer

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

Definition at line 1027 of file JArray.hh.


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