Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 Tconst_pointer
 
typedef Tpointer
 
typedef const Tconst_iterator
 
typedef Titerator
 
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
 
typedef std::reverse_iterator
< iterator
reverse_iterator
 
typedef Treference
 
typedef const Tconst_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 x)
 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...
 
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

T buffer [1]
 

Friends

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

Member Typedef Documentation

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

Definition at line 608 of file JArray.hh.

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

Definition at line 609 of file JArray.hh.

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

Definition at line 610 of file JArray.hh.

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

Definition at line 611 of file JArray.hh.

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

Definition at line 612 of file JArray.hh.

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

Definition at line 613 of file JArray.hh.

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

Definition at line 614 of file JArray.hh.

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

Definition at line 615 of file JArray.hh.

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

Definition at line 616 of file JArray.hh.

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

Definition at line 617 of file JArray.hh.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 623 of file JArray.hh.

624  {}
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 633 of file JArray.hh.

634  {
635  buffer[0] = array[0];
636  }
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 645 of file JArray.hh.

646  {
647  buffer[0] = array[0];
648  }
template<class T >
JTOOLS::JArray< 1, T >::JArray ( const T p)
inline

Copy constructor.

Parameters
ppointer to data

Definition at line 656 of file JArray.hh.

657  {
658  buffer[0] = p[0];
659  }
template<class T >
JTOOLS::JArray< 1, T >::JArray ( const JMultiKey< 1, T > &  key)
inline

Copy constructor.

Parameters
keymulti-dimensional key

Definition at line 667 of file JArray.hh.

668  {
669  buffer[0] = key.first;
670  }
template<class T >
JTOOLS::JArray< 1, T >::JArray ( const JMultiKey< 1, const T > &  key)
inline

Copy constructor.

Parameters
keymulti-dimensional key

Definition at line 678 of file JArray.hh.

679  {
680  buffer[0] = key.first;
681  }
template<class T >
JTOOLS::JArray< 1, T >::JArray ( argument_type  x)
inline

Initialise constructor.

Parameters
xvalue;

Definition at line 689 of file JArray.hh.

690  {
691  buffer[0] = x;
692  }

Member Function Documentation

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

get iterator to begin of data

Definition at line 695 of file JArray.hh.

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

get iterator to end of data

Definition at line 696 of file JArray.hh.

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

get iterator to begin of data

Definition at line 699 of file JArray.hh.

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

get iterator to end of data

Definition at line 700 of file JArray.hh.

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

get reverse iterator to begin of data

Definition at line 703 of file JArray.hh.

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

get reverse iterator to begin of data

Definition at line 704 of file JArray.hh.

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

get reverse iterator to begin of data

Definition at line 707 of file JArray.hh.

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

get reverse iterator to end of data

Definition at line 708 of file JArray.hh.

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

718  {
719  return buffer[index];
720  }
template<class T >
reference JTOOLS::JArray< 1, T >::operator[] ( int  index)
inline

Get element at given index.

Parameters
indexindex
Returns
element

Definition at line 729 of file JArray.hh.

730  {
731  return buffer[index];
732  }
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 741 of file JArray.hh.

742  {
743  if (index >= 0 && index < N)
744  return buffer[index];
745  else
746  throw JIndexOutOfRange("JArray<>::at()");
747  }
static const unsigned int N
Definition: JArray.hh:606
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 756 of file JArray.hh.

757  {
758  if (index >= 0 && index < N)
759  return buffer[index];
760  else
761  throw JIndexOutOfRange("JArray<>::at()");
762  }
static const unsigned int N
Definition: JArray.hh:606
template<class T >
const_pointer JTOOLS::JArray< 1, T >::data ( ) const
inline

Get pointer to data.

Returns
pointer to data

Definition at line 770 of file JArray.hh.

771  {
772  return buffer;
773  }
template<class T >
pointer JTOOLS::JArray< 1, T >::data ( )
inline

Get pointer to data.

Returns
pointer to data

Definition at line 781 of file JArray.hh.

782  {
783  return buffer;
784  }
template<class T >
static size_type JTOOLS::JArray< 1, T >::size ( )
inlinestatic

Get size of data.

Returns
size of data

Definition at line 792 of file JArray.hh.

793  {
794  return N;
795  }
static const unsigned int N
Definition: JArray.hh:606
template<class T >
JArray& JTOOLS::JArray< 1, T >::negate ( )
inline

Negate array.

Returns
this array

Definition at line 803 of file JArray.hh.

804  {
805  buffer[0] = -buffer[0];
806 
807  return *this;
808  }
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 817 of file JArray.hh.

818  {
819  buffer[0] += array[0];
820 
821  return *this;
822  }
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 831 of file JArray.hh.

832  {
833  buffer[0] -= array[0];
834 
835  return *this;
836  }
template<class T >
JArray& JTOOLS::JArray< 1, T >::mul ( const double  factor)
inline

Scale array.

Parameters
factormultiplication factor
Returns
this array

Definition at line 845 of file JArray.hh.

846  {
847  buffer[0] *= factor;
848 
849  return *this;
850  }
template<class T >
JArray& JTOOLS::JArray< 1, T >::div ( const double  factor)
inline

Scale array.

Parameters
factordivision factor
Returns
this array

Definition at line 859 of file JArray.hh.

860  {
861  buffer[0] /= factor;
862 
863  return *this;
864  }
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 873 of file JArray.hh.

874  {
875  return buffer[0] == array[0];
876  }
template<class JFirst_t, class JSecond_t = JNullType>
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 357 of file JMath.hh.

358  {
359  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
360  }
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18

Friends And Related Function Documentation

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

Read array from input.

Parameters
inreader
bufferarray
Returns
reader

Definition at line 886 of file JArray.hh.

887  {
888  return in >> buffer[0];
889  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
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 899 of file JArray.hh.

900  {
901  return out << buffer[0];
902  }

Member Data Documentation

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

Definition at line 606 of file JArray.hh.

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

Definition at line 905 of file JArray.hh.


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