ASL
Array_< T, N > Class Template Reference

Detailed Description

template<class T, int N>
class asl::Array_< T, N >

This class represents a fixed-length array.

It is similar to Array but the array length is fixed and must be known at compile time. It is much faster to create and copy than a dynamic Array.

Array_<int,2> getMinMax()
{
return array_(min, max); // or C++11: return {min, max};
}
Array_< T, 2 > array_(const T &a0, const T &a1)
Creates an array with the 2 elements given as arguments (there are overloads from 1 to 6 elements)
Definition: Array_.h:233

#include <Array_.h>

Public Member Functions

int length () const
 Returns the number of elements in the array.
 
 operator const T * () const
 Returns a pointer to the base of the array.
 
bool operator== (const Array_ &b) const
 Tests for equality of all elements of both arrays.
 
const T & operator[] (int i) const
 Returns the element at index i.
 
T & operator[] (int i)
 Returns the element at index i.
 
const T & last () const
 Returns a reference to the last element.
 
T & last ()
 Returns a reference to the last element.
 
int indexOf (const T &x, int j=0) const
 Returns the index of the first element with value x. More...
 
bool contains (const T &x) const
 Returns true if the array contains an element equal to x.
 
Array_operator= (const Array_ &b)
 Assigns array b into this array by reference.
 
Array_sort ()
 Sorts the array using the elements' < operator "in place".
 
template<class Less >
Array_sort (Less f)
 Sorts the array using the elements' < operator "in place".
 
String join (const String &sep) const
 Returns a string representation of the array, formed by joining its elements with the given separator string sep. More...
 

Member Function Documentation

◆ indexOf()

int indexOf ( const T &  x,
int  j = 0 
) const
inline

Returns the index of the first element with value x.

The search starts at position j. The value -1 is returned if no such element is found

◆ join()

String join ( const String sep) const

Returns a string representation of the array, formed by joining its elements with the given separator string sep.

The elements need to be convertible to String


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