Jpp
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
JTOOLS::JArray< 1, const T > Class Template Reference

One dimensional read-only array of template objects with fixed length. More...

#include <JArray.hh>

Public Types

typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef unsigned int size_type
 

Public Member Functions

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...
 
const_iterator begin () const
 get iterator to begin of data More...
 
const_iterator end () const
 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 end of data More...
 
const_reference operator[] (int index) const
 Get element at given index. More...
 
const_reference at (int index) const
 Get element at given index. More...
 
const_pointer data () const
 Get pointer to data. More...
 

Static Public Member Functions

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

Public Attributes

const typedef T * const_pointer
 
const typedef T * const_iterator
 
const typedef T & const_reference
 

Static Public Attributes

static const unsigned int N = 1
 

Protected Member Functions

 JArray (const T *__p)
 Constructor. More...
 

Protected Attributes

const_pointer p
 

Friends

class JArray< N+1, const T >
 
JWriteroperator<< (JWriter &out, const JArray &buffer)
 Write array to output. More...
 

Detailed Description

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

One dimensional read-only array of template objects with fixed length.

The internal data structure consists of a simple C-pointer to the actual data. The user should ensure that the data are persistent.

Definition at line 979 of file JArray.hh.

Member Typedef Documentation

◆ const_reverse_iterator

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

Definition at line 988 of file JArray.hh.

◆ size_type

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

Definition at line 990 of file JArray.hh.

Constructor & Destructor Documentation

◆ JArray() [1/3]

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

Copy constructor.

Parameters
arrayarray

Definition at line 999 of file JArray.hh.

999  :
1000  p(array.data())
1001  {
1002  STATIC_CHECK(M >= N);
1003  }

◆ JArray() [2/3]

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

Copy constructor.

Parameters
arrayarray

Definition at line 1012 of file JArray.hh.

1012  :
1013  p(array.data())
1014  {
1015  STATIC_CHECK(M >= N);
1016  }

◆ JArray() [3/3]

template<class T >
JTOOLS::JArray< 1, const T >::JArray ( const T *  __p)
inlineprotected

Constructor.

Parameters
__ppointer to data

Definition at line 1097 of file JArray.hh.

1097  :
1098  p(__p)
1099  {}

Member Function Documentation

◆ begin()

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

get iterator to begin of data

Definition at line 1019 of file JArray.hh.

◆ end()

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

get iterator to end of data

Definition at line 1020 of file JArray.hh.

◆ rbegin()

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

get reverse iterator to begin of data

Definition at line 1023 of file JArray.hh.

◆ rend()

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

get reverse iterator to end of data

Definition at line 1024 of file JArray.hh.

◆ operator[]()

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

Get element at given index.

Parameters
indexindex
Returns
element at index

Definition at line 1033 of file JArray.hh.

1034  {
1035  return p[index];
1036  }

◆ at()

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

Get element at given index.

Parameters
indexindex
Returns
element at index

Definition at line 1045 of file JArray.hh.

1046  {
1047  if (index >= 0 && index < N)
1048  return p[index];
1049  else
1050  throw JIndexOutOfRange("JArray<>::at()");
1051  }

◆ data()

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

Get pointer to data.

Returns
pointer to data

Definition at line 1059 of file JArray.hh.

1060  {
1061  return p;
1062  }

◆ size()

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

Get size of data.

Returns
size of data

Definition at line 1070 of file JArray.hh.

1071  {
1072  return N;
1073  }

Friends And Related Function Documentation

◆ JArray< N+1, const T >

template<class T >
friend class JArray< N+1, const T >
friend

Definition at line 984 of file JArray.hh.

◆ operator<<

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

Write array to output.

Parameters
outwriter
bufferarray
Returns
writer

Definition at line 1083 of file JArray.hh.

1084  {
1085  return out << buffer[0];
1086  }

Member Data Documentation

◆ const_pointer

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

Definition at line 986 of file JArray.hh.

◆ const_iterator

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

Definition at line 987 of file JArray.hh.

◆ const_reference

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

Definition at line 989 of file JArray.hh.

◆ N

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

Definition at line 982 of file JArray.hh.

◆ p

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

Definition at line 1090 of file JArray.hh.


The documentation for this class was generated from the following file:
JTOOLS::JArray< 1, const T >::N
static const unsigned int N
Definition: JArray.hh:982
STATIC_CHECK
#define STATIC_CHECK(expr)
Definition: JAssert.hh:29
JTOOLS::JArray::data
const_pointer data() const
Get pointer to data.
Definition: JArray.hh:263
JTOOLS::JArray< 1, const T >::p
const_pointer p
Definition: JArray.hh:1090