LevelS C++ support library  3.83
Public Member Functions | List of all members
arrT< T, stm > Class Template Reference

#include <arr.h>

Inheritance diagram for arrT< T, stm >:
arr_ref< T >

Public Member Functions

 arrT ()
 
 arrT (tsize sz)
 
 arrT (tsize sz, const T &inival)
 
 arrT (T *ptr, tsize sz)
 
 arrT (const arrT &orig)
 
 ~arrT ()
 
void alloc (tsize sz)
 
void allocAndFill (tsize sz, const T &inival)
 
void dealloc ()
 
void resize (tsize sz)
 
arrToperator= (const arrT &orig)
 
template<typename T2 >
void copyFrom (const std::vector< T2 > &orig)
 
template<typename T2 >
void copyTo (std::vector< T2 > &vec) const
 
template<typename T2 >
void copyFromPtr (const T2 *ptr, tsize sz)
 
void transfer (arrT &other)
 
void swap (arrT &other)
 
- Public Member Functions inherited from arr_ref< T >
 arr_ref (T *d_, tsize s_)
 
tsize size () const
 
void fill (const T &val)
 
template<typename T2 >
T & operator[] (T2 n)
 
template<typename T2 >
const T & operator[] (T2 n) const
 
T * begin ()
 
T * end ()
 
const T * begin () const
 
const T * end () const
 
template<typename T2 >
void copyToPtr (T *ptr) const
 
void sort ()
 
template<typename Comp >
void sort (Comp comp)
 
void interpol_helper (const T &val, tsize &idx, double &frac) const
 
template<typename Comp >
void interpol_helper (const T &val, Comp comp, tsize &idx, double &frac) const
 
void minmax (T &minv, T &maxv) const
 
bool contains (const T &val) const
 
tsize find (const T &val) const
 
bool contentsEqual (const arr_ref &other) const
 

Detailed Description

template<typename T, typename stm>
class arrT< T, stm >

One-dimensional array type, with selectable storage management.

Definition at line 177 of file arr.h.

Constructor & Destructor Documentation

◆ arrT() [1/5]

template<typename T, typename stm>
arrT< T, stm >::arrT ( )
inline

Creates a zero-sized array.

Definition at line 187 of file arr.h.

◆ arrT() [2/5]

template<typename T, typename stm>
arrT< T, stm >::arrT ( tsize  sz)
inlineexplicit

Creates an array with sz entries.

Definition at line 189 of file arr.h.

◆ arrT() [3/5]

template<typename T, typename stm>
arrT< T, stm >::arrT ( tsize  sz,
const T &  inival 
)
inline

Creates an array with sz entries, and initializes them with inival.

Definition at line 192 of file arr.h.

◆ arrT() [4/5]

template<typename T, typename stm>
arrT< T, stm >::arrT ( T *  ptr,
tsize  sz 
)
inline

Creates an array with sz entries, which uses the memory pointed to by ptr.

Note
ptr will not be deallocated by the destructor.
Warning
Only use this if you REALLY know what you are doing. In particular, this is only safely usable if
  • T is a POD type
  • ptr survives during the lifetime of the array object
  • ptr is not subject to garbage collection
Other restrictions may apply. You have been warned.

Definition at line 205 of file arr.h.

◆ arrT() [5/5]

template<typename T, typename stm>
arrT< T, stm >::arrT ( const arrT< T, stm > &  orig)
inline

Creates an array which is a copy of orig. The data in orig is duplicated.

Definition at line 208 of file arr.h.

◆ ~arrT()

template<typename T, typename stm>
arrT< T, stm >::~arrT ( )
inline

Frees the memory allocated by the object.

Definition at line 211 of file arr.h.

Member Function Documentation

◆ alloc()

template<typename T, typename stm>
void arrT< T, stm >::alloc ( tsize  sz)
inline

Allocates space for sz elements. The content of the array is undefined on exit. sz can be 0. If sz is the same as the current size, no reallocation is performed.

Definition at line 216 of file arr.h.

◆ allocAndFill()

template<typename T, typename stm>
void arrT< T, stm >::allocAndFill ( tsize  sz,
const T &  inival 
)
inline

Allocates space for sz elements. If sz is the same as the current size, no reallocation is performed. All elements are set to inival.

Definition at line 227 of file arr.h.

◆ dealloc()

template<typename T, typename stm>
void arrT< T, stm >::dealloc ( )
inline

Deallocates the memory held by the array, and sets the array size to 0.

Definition at line 231 of file arr.h.

◆ resize()

template<typename T, typename stm>
void arrT< T, stm >::resize ( tsize  sz)
inline

Resizes the array to hold sz elements. The existing content of the array is copied over to the new array to the extent possible. sz can be 0. If sz is the same as the current size, no reallocation is performed.

Definition at line 236 of file arr.h.

◆ operator=()

template<typename T, typename stm>
arrT& arrT< T, stm >::operator= ( const arrT< T, stm > &  orig)
inline

Changes the array to be a copy of orig.

Definition at line 250 of file arr.h.

◆ copyFrom()

template<typename T, typename stm>
template<typename T2 >
void arrT< T, stm >::copyFrom ( const std::vector< T2 > &  orig)
inline

Changes the array to be a copy of the std::vector orig.

Definition at line 259 of file arr.h.

◆ copyTo()

template<typename T, typename stm>
template<typename T2 >
void arrT< T, stm >::copyTo ( std::vector< T2 > &  vec) const
inline

Changes the std::vector vec to be a copy of the object.

Definition at line 265 of file arr.h.

◆ copyFromPtr()

template<typename T, typename stm>
template<typename T2 >
void arrT< T, stm >::copyFromPtr ( const T2 *  ptr,
tsize  sz 
)
inline

Reserves space for sz elements, then copies sz elements from ptr into the array.

Definition at line 273 of file arr.h.

◆ transfer()

template<typename T, typename stm>
void arrT< T, stm >::transfer ( arrT< T, stm > &  other)
inline

Assigns the contents and size of other to the array.

Note
On exit, other is zero-sized!

Definition at line 281 of file arr.h.

◆ swap()

template<typename T, typename stm>
void arrT< T, stm >::swap ( arrT< T, stm > &  other)
inline

Swaps contents and size with other.

Definition at line 290 of file arr.h.


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

Generated on Wed Nov 13 2024 12:18:16 for LevelS C++ support library