Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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 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< 1, 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.
 

Static Public Member Functions

static size_type size ()
 Get size of data.
 

Static Public Attributes

static const unsigned int N = 1
 

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

Member Typedef Documentation

◆ const_pointer

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

Definition at line 1209 of file JArray.hh.

◆ const_iterator

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

Definition at line 1210 of file JArray.hh.

◆ const_reverse_iterator

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

Definition at line 1211 of file JArray.hh.

◆ const_reference

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

Definition at line 1212 of file JArray.hh.

◆ size_type

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

Definition at line 1213 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 1222 of file JArray.hh.

1222 :
1223 p(array.data())
1224 {
1225 STATIC_CHECK(M >= N);
1226 }
#define STATIC_CHECK(expr)
Definition JAssert.hh:31
static const unsigned int N
Definition JArray.hh:1205

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

1235 :
1236 p(array.data())
1237 {
1238 STATIC_CHECK(M >= N);
1239 }

◆ JArray() [3/3]

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

Constructor.

Parameters
__ppointer to data

Definition at line 1331 of file JArray.hh.

1331 :
1332 p(__p)
1333 {}

Member Function Documentation

◆ operator JMultiKey< 1, const T >()

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

Type conversion operator.

Returns
multi-key

Definition at line 1247 of file JArray.hh.

1248 {
1249 return JMultiKey<1, const T>(p[0]);
1250 }

◆ begin()

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

get iterator to begin of data

Definition at line 1253 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 1254 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 1257 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 1258 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 1267 of file JArray.hh.

1268 {
1269 return p[index];
1270 }

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

1280 {
1281 if (index >= 0 && index < N)
1282 return p[index];
1283 else
1284 THROW(JIndexOutOfRange, "invalid index " << 0 << " <= " << index << " < " << N);
1285 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.

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

1294 {
1295 return p;
1296 }

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

1305 {
1306 return N;
1307 }

Friends And Related Symbol Documentation

◆ JArray< N+1, const T >

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

Definition at line 1205 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 1317 of file JArray.hh.

1318 {
1319 return out << buffer[0];
1320 }

Member Data Documentation

◆ N

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

Definition at line 1205 of file JArray.hh.

◆ p

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

Definition at line 1324 of file JArray.hh.


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