Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JTOOLS::JArray< N, const T > Class Template Reference

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

#include <JArray.hh>

Public Types

typedef const T * const_pointer
 
typedef const T * const_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef const T & const_reference
 
typedef unsigned int size_type
 

Public Member Functions

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.
 
 operator JMultiKey< N, const 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
 
const_reverse_iterator rbegin () const
 get reverse iterator to begin of data
 
const_reverse_iterator rend () const
 get reverse iterator to end of data
 
const_reference operator[] (int index) const
 Get element at given index.
 
const_reference at (int index) const
 Get element at given index.
 
const_pointer data () const
 Get pointer to data.
 
JArray< N-1, const T > pop_front () const
 Make a copy in which the first element is removed.
 
JArray< N-1, const T > pop_back () const
 Make a copy in which the last element is removed.
 

Static Public Member Functions

static size_type size ()
 Get size of data.
 

Protected Member Functions

 JArray (const T *__p)
 Constructor.
 

Protected Attributes

const_pointer p
 

Friends

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

Detailed Description

template<unsigned int N, class T>
class JTOOLS::JArray< N, 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 1037 of file JArray.hh.

Member Typedef Documentation

◆ const_pointer

template<unsigned int N, class T >
const T* JTOOLS::JArray< N, const T >::const_pointer

Definition at line 1042 of file JArray.hh.

◆ const_iterator

template<unsigned int N, class T >
const T* JTOOLS::JArray< N, const T >::const_iterator

Definition at line 1043 of file JArray.hh.

◆ const_reverse_iterator

template<unsigned int N, class T >
std::reverse_iterator<const_iterator> JTOOLS::JArray< N, const T >::const_reverse_iterator

Definition at line 1044 of file JArray.hh.

◆ const_reference

template<unsigned int N, class T >
const T& JTOOLS::JArray< N, const T >::const_reference

Definition at line 1045 of file JArray.hh.

◆ size_type

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

Definition at line 1046 of file JArray.hh.

Constructor & Destructor Documentation

◆ JArray() [1/3]

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

Copy constructor.

Parameters
arrayarray

Definition at line 1055 of file JArray.hh.

1055 :
1056 p(array.data())
1057 {
1058 STATIC_CHECK(M >= N);
1059 }
#define STATIC_CHECK(expr)
Definition JAssert.hh:31

◆ JArray() [2/3]

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

Copy constructor.

Parameters
arrayarray

Definition at line 1068 of file JArray.hh.

1068 :
1069 p(array.data())
1070 {
1071 STATIC_CHECK(M >= N);
1072 }

◆ JArray() [3/3]

template<unsigned int N, class T >
JTOOLS::JArray< N, const T >::JArray ( const T * __p)
inlineprotected

Constructor.

Parameters
__ppointer to data

Definition at line 1190 of file JArray.hh.

1190 :
1191 p(__p)
1192 {}

Member Function Documentation

◆ operator JMultiKey< N, const T >()

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

Type conversion operator.

Returns
multi-key

Definition at line 1080 of file JArray.hh.

1081 {
1082 return JMultiKey<N, const T>(p[0], this->pop_front());
1083 }
JArray< N-1, const T > pop_front() const
Make a copy in which the first element is removed.
Definition JArray.hh:1148

◆ begin()

template<unsigned int N, class T >
const_iterator JTOOLS::JArray< N, const T >::begin ( ) const
inline

get iterator to begin of data

Definition at line 1086 of file JArray.hh.

◆ end()

template<unsigned int N, class T >
const_iterator JTOOLS::JArray< N, const T >::end ( ) const
inline

get iterator to end of data

Definition at line 1087 of file JArray.hh.

◆ rbegin()

template<unsigned int N, class T >
const_reverse_iterator JTOOLS::JArray< N, const T >::rbegin ( ) const
inline

get reverse iterator to begin of data

Definition at line 1090 of file JArray.hh.

◆ rend()

template<unsigned int N, class T >
const_reverse_iterator JTOOLS::JArray< N, const T >::rend ( ) const
inline

get reverse iterator to end of data

Definition at line 1091 of file JArray.hh.

◆ operator[]()

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

Get element at given index.

Parameters
indexindex
Returns
element at index

Definition at line 1100 of file JArray.hh.

1101 {
1102 return p[index];
1103 }

◆ at()

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

Get element at given index.

Parameters
indexindex
Returns
element at index

Definition at line 1112 of file JArray.hh.

1113 {
1114 if (index >= 0 && index < N)
1115 return p[index];
1116 else
1117 THROW(JIndexOutOfRange, "invalid index " << 0 << " <= " << index << " < " << N);
1118 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.

◆ data()

template<unsigned int N, class T >
const_pointer JTOOLS::JArray< N, const T >::data ( ) const
inline

Get pointer to data.

Returns
pointer to data

Definition at line 1126 of file JArray.hh.

1127 {
1128 return p;
1129 }

◆ size()

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

Get size of data.

Returns
size of data

Definition at line 1137 of file JArray.hh.

1138 {
1139 return N;
1140 }

◆ pop_front()

template<unsigned int N, class T >
JArray< N-1, const T > JTOOLS::JArray< N, const T >::pop_front ( ) const
inline

Make a copy in which the first element is removed.

Returns
array

Definition at line 1148 of file JArray.hh.

1149 {
1150 return JArray<N-1, const T>(p + 1);
1151 }
JArray(const JArray< M, T > &array)
Copy constructor.
Definition JArray.hh:1055

◆ pop_back()

template<unsigned int N, class T >
JArray< N-1, const T > JTOOLS::JArray< N, const T >::pop_back ( ) const
inline

Make a copy in which the last element is removed.

Returns
array

Definition at line 1159 of file JArray.hh.

1160 {
1161 return JArray<N-1, const T>(p);
1162 }

Friends And Related Symbol Documentation

◆ JArray< N+1, const T >

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

Definition at line 1027 of file JArray.hh.

◆ operator<<

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

Write array to output.

Parameters
outwriter
bufferarray
Returns
writer

Definition at line 1172 of file JArray.hh.

1173 {
1174 for (const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
1175 out << *i;
1176 }
1177
1178 return out;
1179 }

Member Data Documentation

◆ p

template<unsigned int N, class T >
const_pointer JTOOLS::JArray< N, const T >::p
protected

Definition at line 1183 of file JArray.hh.


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