Itasca C++ Interface
Loading...
Searching...
No Matches
FArray< T, 0 > Class Template Reference

#include <farray.h>

Inheritance diagram for FArray< T, 0 >:

Public Types

using size_type
 Typedef to assist in STL compatibility.
using value_type
 Typedef to assist in STL compatibility.
using iterator
 Typedef to assist in STL compatibility.
using const_iterator
 Typedef to assist in STL compatibility.

Public Member Functions

constexpr FArray ()
 Default constructor - the array size is zero.
 ~FArray ()
 Destructor.
constexpr const FArray< T, S, uint64 > & operator= (const FArray< T, S, uint64 > &f)
bool operator== (const FArray< T, S2, uint64 > &f) const
uint64 size () const
size_type stackSize () const
 Returns the size of the array pre-allocated on the stack.
size_type allocated () const
bool empty () const
T * data ()
T & front ()
T & back ()
uint64 find (const T &t) const
size_type capacity () const
void push_back (const T &t)
 Adds a new element to the end of the array, increasing the array size by one.
T * emplace_back ()
T * emplace_n_back (size_type n)
void pop_back ()
 Removes the last element in the array. The results are undefined if the array is of zero length.
void resize (uint64 i, const T &t=T())
iterator insert (uint64 i, const T &t)
void put (uint64 i, const T &t)
 Adds a value to the array, first making certain it is big enough to hold it.
void append (const C &in)
 Appends the contents of one FArray onto another.
bool remove (uint64 i)
size_type removeAll (const T &t)
void clear ()
void reset ()
void reserve (size_type s)
void clip ()
iterator begin ()
const_iterator constBegin () const
iterator end ()
const_iterator constEnd () const
T & at (uint64 i)
T & operator[] (uint64 i)
value (uint64 i, const T &t={}) const

Public Attributes

T * start_
std::array< T, S > arr_
char buffer [sizeof(T) *S]

Detailed Description

template<class T>
class FArray< T, 0 >

Template specialization for S=0 - indication no stack space at all should be made. MOO NOTE: THere is no reason to use this any more, as a std::vector will leave the capacity unchanged which was the primary reason to use this.

Member Function Documentation

◆ allocated()

size_type FArray< T, S, uint64 >::allocated ( ) const
inline
Returns
the size allocated internally – this will be S (the stack length) unless the array has been made large enough to force heap access.

◆ at()

T & FArray< T, S, uint64 >::at ( uint64 i)
inline
Returns
A reference to the element at the ith location in the array. Undefined if the array length is less than or equal to i. No bounds checking is performed, even in a debug compile.

◆ back()

T & FArray< T, S, uint64 >::back ( )
inline
Returns
a reference to the last element in the array. This is undefined if the array is of zero length.

◆ begin()

iterator FArray< T, S, uint64 >::begin ( )
inline
Returns
An iterator representing the first element in the array. Implemented as a pointer. STL compatible as a random-access iterator.

◆ clear()

void FArray< T, S, uint64 >::clear ( )

Resets the array size to zero, destroying all current elements. The allocated length is not changed.

◆ clip()

void FArray< T, S, uint64 >::clip ( )
inline

Reduces the allocated length to the actual length of the array, or the stack length, whichever is greater. This and reset() are the only means of reducing the allocated length of an existing FArray.

◆ constBegin()

const_iterator FArray< T, S, uint64 >::constBegin ( ) const
inline
Returns
An iterator representing the first element in the array. Implemented as a pointer. STL compatible as a random-access iterator.

◆ constEnd()

const_iterator FArray< T, S, uint64 >::constEnd ( ) const
inline
Returns
An iterator representing one past the last element in the array. Implemented as a pointer. STL compatible as a random-access iterator.

◆ data()

T * FArray< T, S, uint64 >::data ( )
inline
Returns
a pointer to the beginning of the array data. An FARRAY guarantees that it's internal data is contiguous.

◆ emplace_back()

T * FArray< T, S, uint64 >::emplace_back ( )
inline

To avoid creating a temporary object, can call this to get memory location of new lcoation at end of stack and then use it to do an in-place new. new(fa.emplace_back()) Fred(arg1,arg2);

◆ emplace_n_back()

T * FArray< T, S, uint64 >::emplace_n_back ( size_type n)

emplace_n_back: make sure n new positions are allocated and return a pointer to the first of those positions; caller should create objects at those positions.

◆ empty()

bool FArray< T, S, uint64 >::empty ( ) const
inline
Returns
true if the array is of zero length.

◆ end()

iterator FArray< T, S, uint64 >::end ( )
inline
Returns
An iterator representing one past the last element in the array. Implemented as a pointer. STL compatible as a random-access iterator.

◆ find()

uint64 FArray< T, S, uint64 >::find ( const T & t) const

Searches the array to find the first element matching t. Returns the index found, or limits<size_type>::max() if not found. This search is linear time.

◆ front()

T & FArray< T, S, uint64 >::front ( )
inline
Returns
a reference to the first element in the array. This is undefined if the array is of zero length.

◆ insert()

FArray< T, S, uint64 >::iterator FArray< T, S, uint64 >::insert ( uint64 i,
const T & t )

Inserts a value into the array at position i (the new position it will occupy). If I is past the end of the array, adds to end.

◆ operator[]()

T & FArray< T, S, uint64 >::operator[] ( uint64 i)
inline
Returns
A reference to the element at the ith location in the array. Undefined if the array length is less than or equal to i. No bounds checking is performed, even in a debug compile.

◆ remove()

bool FArray< T, S, uint64 >::remove ( uint64 i)

Removes a value from the array at position i If i is past the end of the array, does nothing.

◆ removeAll()

FArray< T, S, uint64 >::size_type FArray< T, S, uint64 >::removeAll ( const T & t)

Removes all values from the array matching t (operator==). Returns the number of objects removed

◆ reset()

void FArray< T, S, uint64 >::reset ( )

Resets the array size to zero, destroying all current elements. The allocated length is reset back to the stack length, and any heap memory is returned.

◆ resize()

void FArray< T, S, uint64 >::resize ( uint64 i,
const T & t = T() )
Parameters
iThe new array length.
tThe value assigned to new array elements (if any). Changes the actual length (not the allocated length) of the array to i. May increase the allocated length, but will not decrease it.

◆ size()

uint64 FArray< T, S, uint64 >::size ( ) const
inline
Returns
the current size of the array - NOT the stack length OR the size allocated internally.

◆ value()

T FArray< T, S, uint64 >::value ( uint64 i,
const T & t = {} ) const
inline
Returns
A copy of the value at the ith location in the array, or t if i is an invalid index.

The documentation for this class was generated from the following file:
  • C:/Source/itasca-suite/common/base/src/farray.h