Lolly 1.4.28
Loading...
Searching...
No Matches
Private Member Functions | List of all members
array< T > Class Template Reference

A template class representing an array. More...

#include <array.hpp>

Inheritance diagram for array< T >:
Inheritance graph
[legend]

Private Member Functions

 CONCRETE_TEMPLATE (array, T)
 
 array (int n=0)
 Construct a new array object with length 0.
 
 array (T *a, int n)
 Construct a new array object from a C array with specified length.
 
 array (T x1, T x2)
 Construct a new array object with two elements.
 
 array (T x1, T x2, T x3)
 Construct a new array object with three elements.
 
 array (T x1, T x2, T x3, T x4)
 Construct a new array object with four elements.
 
 array (T x1, T x2, T x3, T x4, T x5)
 Construct a new array object with five elements.
 
T & operator[] (int i)
 Get a reference to the element atthe specified index.
 
T * begin ()
 
T * end ()
 

Detailed Description

template<class T>
class array< T >

A template class representing an array.

Template Parameters
TType of elements in the array.

Definition at line 95 of file array.hpp.

Constructor & Destructor Documentation

◆ array() [1/6]

template<class T >
array< T >::array ( int n = 0)
inlineprivate

Construct a new array object with length 0.

Definition at line 101 of file array.hpp.

101: rep (tm_new<array_rep<T>> (n)) {}
The list class represents a linked list.
Definition list.hpp:48
C * tm_new()
base class of resources
Definition resource.hpp:23

◆ array() [2/6]

template<class T >
array< T >::array ( T * a,
int n )
private

Construct a new array object from a C array with specified length.

Template Parameters
TType of elements in the array.
Parameters
aThe C array.
nThe length of the C array.

Definition at line 57 of file array.ipp.

57 {
58 int i;
60 for (i= 0; i < n; i++)
61 rep->a[i]= a[i];
62}

◆ array() [3/6]

template<class T >
array< T >::array ( T x1,
T x2 )
private

Construct a new array object with two elements.

Template Parameters
TType of elements in the array.
Parameters
x1The first element.
x2The second element.

Definition at line 64 of file array.ipp.

64 {
66 rep->a[0]= x1;
67 rep->a[1]= x2;
68}

◆ array() [4/6]

template<class T >
array< T >::array ( T x1,
T x2,
T x3 )
private

Construct a new array object with three elements.

Template Parameters
TType of elements in the array.
Parameters
x1The first element.
x2The second element.
x3The third element.

Definition at line 70 of file array.ipp.

70 {
72 rep->a[0]= x1;
73 rep->a[1]= x2;
74 rep->a[2]= x3;
75}

◆ array() [5/6]

template<class T >
array< T >::array ( T x1,
T x2,
T x3,
T x4 )
private

Construct a new array object with four elements.

Template Parameters
TType of elements in the array.
Parameters
x1The first element.
x2The second element.
x3The third element.
x4The fourth element.

Definition at line 77 of file array.ipp.

77 {
79 rep->a[0]= x1;
80 rep->a[1]= x2;
81 rep->a[2]= x3;
82 rep->a[3]= x4;
83}

◆ array() [6/6]

template<class T >
array< T >::array ( T x1,
T x2,
T x3,
T x4,
T x5 )
private

Construct a new array object with five elements.

Template Parameters
TType of elements in the array.
Parameters
x1The first element.
x2The second element.
x3The third element.
x4The fourth element.
x5The fifth element.

Definition at line 85 of file array.ipp.

85 {
87 rep->a[0]= x1;
88 rep->a[1]= x2;
89 rep->a[2]= x3;
90 rep->a[3]= x4;
91 rep->a[4]= x5;
92}

Member Function Documentation

◆ CONCRETE_TEMPLATE()

template<class T >
array< T >::CONCRETE_TEMPLATE ( array< T > ,
T  )
private

◆ operator[]()

template<class T >
T & array< T >::operator[] ( int i)
inlineprivate

Get a reference to the element atthe specified index.

Template Parameters
TType of elements in the array.
Parameters
iThe index of the element.
Returns
A reference to the element at the specified index.

Definition at line 161 of file array.hpp.

161{ return rep->a[i]; }

◆ begin()

template<class T >
T * array< T >::begin ( )
inlineprivate

Definition at line 163 of file array.hpp.

163{ return rep->a; }

◆ end()

template<class T >
T * array< T >::end ( )
inlineprivate

Definition at line 164 of file array.hpp.

164{ return rep->a + rep->n; }

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