libzed 1.9.9
A general-purpose library for quick and simple data manipulation.
 
Loading...
Searching...
No Matches
z::core::array< T > Class Template Reference

A wrapper for std::vector. More...

#include <array.hpp>

Inheritance diagram for z::core::array< T >:
z::core::sizable z::core::arrayLike< const T &, T * > z::core::indexable< T > z::core::iterable< ITER > z::core::sortedArray< zstring * > z::core::refArray< T > z::core::sortedArray< T > z::core::sortedRefArray< zstring * > z::core::sortedRefArray< T > z::util::dictionary

Public Member Functions

 array ()
 Default constructor.
 
 array (const array &other)
 Copy constructor.
 
 array (const std::vector< T > &other)
 Copy from std::vector.
 
template<typename... Args>
 array (const T &arg1, const Args &...args)
 List-initialized constructor.
 
 array (const std::initializer_list< T > &other)
 Construct from a generic initializer list.
 
virtual ~array ()
 Destructor.
 
void clear ()
 Clear the data in the array.
 
void increase (int newSize) noexcept
 Increase the space allocated for this array.
 
virtual int add (const T &object)
 Add an object to the array.
 
void add (const array &other) noexcept
 Add another array to this array.
 
int push (const T &object) noexcept
 Add an object to the array.
 
void push (const array &other) noexcept
 Add another array to this array.
 
T pop ()
 Remove the last element from this array.
 
arrayinsert (const T &, int)
 Insert an object into the array.
 
void append (const T &)
 Append an object to the end of the array.
 
arrayremove (int)
 Remove an object from the array.
 
arrayremove (int, int)
 Remove all elements in a subset of the array.
 
arrayreplace (int, int, const T &)
 Replace all objects in the given range with an object.
 
arrayreplace (int, int, const array< T > &)
 Replace all objects in the given range with an array of objects.
 
array subset (int index, int count) const
 Get a contiguous subset of the elements in the array.
 
size_t size () const noexcept override
 Get the size of the array.
 
int length () const noexcept override
 Get the length of the array.
 
Tat (int)
 Function to get the object at the given index.
 
const Tat (int) const override
 Const function to get the object at the given index.
 
const Toperator[] (int index) const override
 Function to get the object at the given index.
 
Toperator[] (int index)
 Function to get the object at the given index.
 
virtual int find (const T &object) const
 Find the index of a given object in the array.
 
bool contains (const T &object) const noexcept
 Check if a given object is in the array.
 
void sort () noexcept
 Sort the array based on default comparison operator.
 
void sort (std::function< bool(const T &, const T &)> lambda) noexcept
 Sort the array based on an arbitrary function.
 
array sorted () const noexcept
 Sort the array based on default comparison operator.
 
array sorted (std::function< bool(const T &, const T &)> lambda) const noexcept
 Sort the array based on an arbitrary function.
 
virtual void shuffle () noexcept
 Shuffle the elements of the array into a random order.
 
array shuffled () const noexcept
 Shuffle the elements of the array into a random order.
 
virtual void reverse () noexcept
 Reverse the order of all elements in the array.
 
array reversed () const noexcept
 Reverse the order of all elements in the array.
 
arrayoperator= (const array &other)
 Array assignment operator.
 
arrayoperator= (const std::initializer_list< T > &other)
 Initializer list assignment operator.
 
bool operator== (const array &other) const
 Check whether two arrays' contents are the same.
 
bool operator> (const array &other) const
 Array greater-than operator.
 
bool operator< (const array &other) const
 Array less-than operator.
 
bool operator>= (const array &other) const
 Array greater-than-or-equal operator.
 
bool operator<= (const array &other) const
 Array less-than-or-equal operator.
 
virtual bool operator() (const T &arg1, const T &arg2) const
 Callable operator.
 
bool isValid (int index) const
 Check if an index is within the bounds of the array.
 
arrayswap (int index1, int index2)
 Swap two elements in an array.
 
template<typename U >
array< Umap (std::function< U(const T &)> lambda) const
 Applies a transformation function to each element of the array and returns a new array with the results.
 
array filter (std::function< bool(const T &)> lambda) const
 Filters the array based on a predicate and returns a new array containing the elements that satisfy the predicate.
 
T reduce (const T &defaultValue, std::function< T(const T &, const T &)> lambda) const
 Reduces the array to a single value by applying a binary operation cumulatively to the elements.
 
T randomElement () const
 Get a random element from the array.
 
array randomElements (int count) const noexcept
 Get N random elements from the array.
 
Tbegin () const noexcept override
 Get pointer to the beginning of the array.
 
Tend () const noexcept override
 Get pointer to the end of the array.
 
void save (cereal::JSONOutputArchive &ar) const
 JSON specialization of serialization output.
 
void save (cereal::XMLOutputArchive &ar) const
 XML specialization of serialization output.
 
template<typename archive >
void save (archive &ar) const
 Binary specialization of serialization output.
 
void load (cereal::JSONInputArchive &ar)
 JSON specialization of serialization input.
 
void load (cereal::XMLInputArchive &ar)
 XML specialization of serialization input.
 
template<class archive >
void load (archive &ar)
 Binary specialization of serialization input.
 
- Public Member Functions inherited from z::core::sizable
virtual ~sizable () noexcept
 Virtual destructor.
 
- Public Member Functions inherited from z::core::indexable< T >
virtual ~indexable () noexcept
 Virtual destructor.
 
- Public Member Functions inherited from z::core::iterable< ITER >
virtual ~iterable () noexcept
 Virtual destructor.
 

Protected Member Functions

void init (const T &arg1)
 Helper function for single object initialization.
 
template<typename... Args>
void init (const T &arg1, const Args &...args)
 Helper function for brace-enclosed list initialization.
 
virtual bool eq (const T &arg1, const T &arg2) const
 Check if two objects are equal.
 
virtual bool gt (const T &arg1, const T &arg2) const
 Check if one object is greater than another.
 
virtual bool lt (const T &arg1, const T &arg2) const
 Check if one object is less than another.
 

Protected Attributes

std::vector< Tarray_data
 The data in the array.
 

Detailed Description

template<typename T>
class z::core::array< T >

A wrapper for std::vector.

This class is a wrapper for the std::vector class that adds ease of use and hides implementation from the user.

/note This will only compile for objects that are copyable. Use std::vector for non-copyable objects.

See also
refArray
sortedArray
sortedRefArray
Examples
array.cpp, chainGenerators.cpp, generator.cpp, and word_unscramble.cpp.

Constructor & Destructor Documentation

◆ array() [1/2]

template<typename T >
template<typename... Args>
z::core::array< T >::array ( const T arg1,
const Args &...  args 
)

List-initialized constructor.

Constructs the array with an arbitrary number of elements already contained.

Syntax: array<T> X {arg1, arg2, ...}; array<T> X = {arg1, arg2, ...};

Parameters
arg1initializing data.
argscont. initializing data.

◆ array() [2/2]

template<typename T >
z::core::array< T >::array ( const std::initializer_list< T > &  other)
inline

Construct from a generic initializer list.

Parameters
otherThe list to initialize this array with.

Member Function Documentation

◆ add() [1/2]

template<typename T >
void z::core::array< T >::add ( const array< T > &  other)
inlinenoexcept

Add another array to this array.

Copies the contents of another array and appends them to the end of this array.

Parameters
otherthe array to copy from.
See also
push()
append()

◆ add() [2/2]

template<typename T >
virtual int z::core::array< T >::add ( const T object)
inlinevirtual

Add an object to the array.

Adds the given data to a position in the array. That position is up to implementation.

Parameters
objectthe data to add to the array.
Returns
The index where the inserted object now resides.
See also
push()
append()

Reimplemented in z::core::sortedArray< T >, and z::core::sortedArray< zstring * >.

◆ append()

template<typename T >
void z::core::array< T >::append ( const T object)

Append an object to the end of the array.

Appends the given data to the end of the array.

Warning
This method ignores any sorting that the current array may have in place! Subsequent searches on sorted arrays may return unpredictable results if used incorrectly.
Parameters
objectthe data to aappend to the array.
See also
add()
push()

◆ at() [1/2]

template<typename T >
T & z::core::array< T >::at ( int  index)

Function to get the object at the given index.

Identical behavior to at(int), but allows indexing with square brackets.

Parameters
indexthe index of the desired object.
Returns
The object at the given index.
Exceptions
std::out_of_rangeif index is an invalid index.
See also
at(int)

◆ at() [2/2]

template<typename T >
const T & z::core::array< T >::at ( int  index) const
overridevirtual

Const function to get the object at the given index.

Identical behavior to at(int), but allows indexing with square brackets.

Parameters
indexthe index of the desired object.
Returns
The object at the given index.
Exceptions
std::out_of_rangeif index is an invalid index.
See also
at(int) const

Implements z::core::indexable< T >.

◆ begin()

template<typename T >
T * z::core::array< T >::begin ( ) const
inlineoverridevirtualnoexcept

Get pointer to the beginning of the array.

This member function should not be used directly. It is meant for C++11's range-based for loop syntax.

Returns
A pointer to the first element in the array. 0 if no elements.

Implements z::core::iterable< ITER >.

◆ contains()

template<typename T >
bool z::core::array< T >::contains ( const T object) const
inlinenoexcept

Check if a given object is in the array.

Parameters
objectthe object to search for.
Returns
true if the object was found in the array, false otherwise.

◆ end()

template<typename T >
T * z::core::array< T >::end ( ) const
inlineoverridevirtualnoexcept

Get pointer to the end of the array.

This member function should not be used directly. It is meant for C++11's range-based for loop syntax.

Returns
A pointer to right after the last element in the array. 0 if no elements.

Implements z::core::iterable< ITER >.

◆ eq()

template<typename T >
virtual bool z::core::array< T >::eq ( const T arg1,
const T arg2 
) const
inlineprotectedvirtual

Check if two objects are equal.

This member function allows object comparison to be different for different array types (e.g. reference arrays will need to sort by value after dereference).

Parameters
arg1First object to compare.
arg2Second object to compare.
Returns
True if the objects are equal, false otherwise.

Reimplemented in z::core::refArray< T >, and z::core::sortedRefArray< T >.

◆ filter()

template<typename T >
array< T > z::core::array< T >::filter ( std::function< bool(const T &)>  lambda) const

Filters the array based on a predicate and returns a new array containing the elements that satisfy the predicate.

This function iterates through the array, applies the given lambda function as a predicate to each element, and adds elements that satisfy the predicate to the resulting array.

Parameters
lambdaA function that takes a constant reference to an element of type T and returns a boolean indicating whether the element should be included.
Returns
A new array containing the elements that satisfy the predicate.
Examples
array.cpp, and word_unscramble.cpp.

◆ find()

template<typename T >
virtual int z::core::array< T >::find ( const T object) const
inlinevirtual

Find the index of a given object in the array.

Locates the desired index using a linear search, as the array is expected to be unsorted.

Parameters
objectthe object to search for.
Returns
The first index that the object was found at. -1 if it was not found.

Reimplemented in z::core::sortedArray< T >, and z::core::sortedArray< zstring * >.

◆ gt()

template<typename T >
virtual bool z::core::array< T >::gt ( const T arg1,
const T arg2 
) const
inlineprotectedvirtual

Check if one object is greater than another.

This member function allows object comparison to be different for different array types (e.g. reference arrays will need to sort by value after dereference).

Parameters
arg1First object to compare.
arg2Second object to compare.
Returns
True if arg1 is greater than arg2, false otherwise.

Reimplemented in z::core::refArray< T >, and z::core::sortedRefArray< T >.

◆ increase()

template<typename T >
void z::core::array< T >::increase ( int  newSize)
inlinenoexcept

Increase the space allocated for this array.

If this array currently has fewer than newSize elements allocated, enough space is reallocated to hold at least that many characters.

Parameters
newSizeThe minimum number of elements this array should be able to contain.

◆ init() [1/2]

template<typename T >
void z::core::array< T >::init ( const T arg1)
inlineprotected

Helper function for single object initialization.

Parameters
arg1The object to initialize the array with.

◆ init() [2/2]

template<typename T >
template<typename... Args>
void z::core::array< T >::init ( const T arg1,
const Args &...  args 
)
inlineprotected

Helper function for brace-enclosed list initialization.

Parameters
arg1The first object to add to the array.
argsAny following objects to add to the array.

◆ insert()

template<typename T >
array< T > & z::core::array< T >::insert ( const T object,
int  index 
)

Insert an object into the array.

Inserts an object into the given index in the array, if possible.

Parameters
objectthe data to add to the array.
indexthe index in the array to insert the object.
Returns
A reference to this array after modification.

◆ isValid()

template<typename T >
bool z::core::array< T >::isValid ( int  index) const

Check if an index is within the bounds of the array.

Parameters
indexthe index to check.
Returns
True if the given index is within array bounds. False otherwise.

◆ length()

template<typename T >
int z::core::array< T >::length ( ) const
overridevirtualnoexcept

Get the length of the array.

Returns
The number of objects in the array.

Implements z::core::arrayLike< const T &, T * >.

Examples
dictionary.cpp, and word_unscramble.cpp.

◆ load() [1/3]

template<typename T >
template<class archive >
void z::core::array< T >::load ( archive ar)
inline

Binary specialization of serialization input.

Parameters
arThe input archive.

◆ load() [2/3]

template<typename T >
void z::core::array< T >::load ( cereal::JSONInputArchive &  ar)
inline

JSON specialization of serialization input.

Parameters
arThe input archive.

◆ load() [3/3]

template<typename T >
void z::core::array< T >::load ( cereal::XMLInputArchive &  ar)
inline

XML specialization of serialization input.

Parameters
arThe input archive.

◆ lt()

template<typename T >
virtual bool z::core::array< T >::lt ( const T arg1,
const T arg2 
) const
inlineprotectedvirtual

Check if one object is less than another.

This member function allows object comparison to be different for different array types (e.g. reference arrays will need to sort by value after dereference).

Parameters
arg1First object to compare.
arg2Second object to compare.
Returns
True if arg1 is less than arg2, false otherwise.

Reimplemented in z::core::refArray< T >, and z::core::sortedRefArray< T >.

◆ map()

template<typename T >
template<typename U >
array< U > z::core::array< T >::map ( std::function< U(const T &)>  lambda) const

Applies a transformation function to each element of the array and returns a new array with the results.

This function iterates through each element of the array, applies the provided lambda function, and stores the result in a new array of type U. The new array is returned after all elements have been processed.

Template Parameters
UThe type of elements in the resulting array.
Parameters
lambdaA function that takes a constant reference to an element of type T and returns an element of type U.
Returns
A new array containing the transformed elements.
Examples
array.cpp, and file.cpp.

◆ operator()()

template<typename T >
bool z::core::array< T >::operator() ( const T arg1,
const T arg2 
) const
virtual

Callable operator.

This is used to compare array elements for sorting.

Parameters
arg1The first element to compare.
arg2The second element to compare.
Returns
true if arg1 is greater than arg2.

Reimplemented in z::core::refArray< T >, and z::core::sortedRefArray< T >.

◆ operator<()

template<typename T >
bool z::core::array< T >::operator< ( const array< T > &  other) const

Array less-than operator.

Parameters
otherthe array to compare with this one.
Returns
True if the difference between the two arrays' elements add to a negative number, or this array has fewer elements. False otherwise.

◆ operator<=()

template<typename T >
bool z::core::array< T >::operator<= ( const array< T > &  other) const
inline

Array less-than-or-equal operator.

Parameters
otherthe array to compare with this one.
Returns
False if the difference between the two arrays' elements add to a positive number, or this array has more elements. True otherwise.

◆ operator=() [1/2]

template<typename T >
array< T > & z::core::array< T >::operator= ( const array< T > &  other)

Array assignment operator.

Clear the contents of this array and create a copy of another array's contents into this one.

Parameters
otherthe array to copy from.
Returns
This array after the operation (for a=b=c type expressions).

◆ operator=() [2/2]

template<typename T >
array< T > & z::core::array< T >::operator= ( const std::initializer_list< T > &  other)

Initializer list assignment operator.

Clear the contents of this array and copy the contents of an initializer list into this array.

Parameters
otherThe initializer list to copy from.
Returns
This array after the operation (for a=b=c type expressions).

◆ operator==()

template<typename T >
bool z::core::array< T >::operator== ( const array< T > &  other) const

Check whether two arrays' contents are the same.

Parameters
otherthe array to compare with this one.
Returns
True if both arrays contain the same contents in the same order, and the same number of contents. False otherwise.

◆ operator>()

template<typename T >
bool z::core::array< T >::operator> ( const array< T > &  other) const

Array greater-than operator.

Parameters
otherthe array to compare with this one.
Returns
True if the difference between the two arrays' elements add to a positive number, or this array has more elements. False otherwise.

◆ operator>=()

template<typename T >
bool z::core::array< T >::operator>= ( const array< T > &  other) const
inline

Array greater-than-or-equal operator.

Parameters
otherthe array to compare with this one.
Returns
False if the difference between the two arrays' elements add to a negative number, or this array has fewer elements. True otherwise.

◆ operator[]() [1/2]

template<typename T >
T & z::core::array< T >::operator[] ( int  index)
inline

Function to get the object at the given index.

Identical behavior to at(int), but allows indexing with square brackets.

Note
This function is used when mutation of an object is needed.
Parameters
indexthe index of the desired object.
Returns
A reference to the object at the given index.
See also
at(int)

◆ operator[]() [2/2]

template<typename T >
const T & z::core::array< T >::operator[] ( int  index) const
inlineoverridevirtual

Function to get the object at the given index.

Identical behavior to at(int), but allows indexing with square brackets.

Note
This function is used when mutation of an object is not needed.
Parameters
indexthe index of the desired object.
Returns
A const reference to the object at the given index.
See also
at(int)

Implements z::core::indexable< T >.

◆ pop()

template<typename T >
T z::core::array< T >::pop ( )
inline

Remove the last element from this array.

Pops the last element, returning it.

Returns
The last element on the array before popping.
Exceptions
std::out_of_rangeif there are no elements in the array.

◆ push() [1/2]

template<typename T >
void z::core::array< T >::push ( const array< T > &  other)
inlinenoexcept

Add another array to this array.

Copies the contents of another array and appends them to the end of this array.

Parameters
otherthe array to copy from.
See also
push()
append()

◆ push() [2/2]

template<typename T >
int z::core::array< T >::push ( const T object)
inlinenoexcept

Add an object to the array.

Adds the given data to a position in the array. That position is up to implementation.

Parameters
objectthe data to add to the array.
Returns
The index where the inserted object now resides.
See also
push()
append()

◆ randomElement()

template<typename T >
T z::core::array< T >::randomElement ( ) const
inline

Get a random element from the array.

Re-Entry: This member function is thread-safe. Simultaneous calls will not cause data races, and any other thread-safe member may be called concurrently without interfering.

Selects a random element from the array, if one exists.

Returns
A random element from the array.
Exceptions
std::out_of_rangeif the array is empty.

◆ randomElements()

template<typename T >
array z::core::array< T >::randomElements ( int  count) const
inlinenoexcept

Get N random elements from the array.

Re-Entry: This member function is thread-safe. Simultaneous calls will not cause data races, and any other thread-safe member may be called concurrently without interfering.

Selects up to N random elements from the array. If N is greater than the size of the array, all elements are returned in a random order.

Parameters
countThe number of random elements to select.
Returns
A new array containing the selected random elements.

◆ reduce()

template<typename T >
T z::core::array< T >::reduce ( const T defaultValue,
std::function< T(const T &, const T &)>  lambda 
) const

Reduces the array to a single value by applying a binary operation cumulatively to the elements.

This function applies a binary operation (provided as a lambda) to combine the elements of the array into a single value. If the array is empty, the provided default value is returned.

Parameters
defaultValueThe value to return if the array is empty.
lambdaA function that takes two elements of type T and returns their combined result of type T.
Returns
The result of the reduction operation.
Examples
array.cpp, and range.cpp.

◆ remove() [1/2]

template<typename T >
array< T > & z::core::array< T >::remove ( int  index)

Remove an object from the array.

Parameters
indexthe index of the object to be removed.
Returns
A reference to this array after modification.

◆ remove() [2/2]

template<typename T >
array< T > & z::core::array< T >::remove ( int  index,
int  count 
)

Remove all elements in a subset of the array.

Parameters
indexthe index of the first object to be removed.
countthe number of objects to be removed.
Returns
A reference to this array after modification.

◆ replace() [1/2]

template<typename T >
array< T > & z::core::array< T >::replace ( int  index,
int  count,
const array< T > &  other 
)

Replace all objects in the given range with an array of objects.

Parameters
indexthe index of the first object to replace.
countthe number of objects to replace.
otherthe array to copy from.
Returns
A reference to this array after modification.
See also
replace(int,int,const T&)

◆ replace() [2/2]

template<typename T >
array< T > & z::core::array< T >::replace ( int  index,
int  count,
const T object 
)

Replace all objects in the given range with an object.

Parameters
indexthe index of the first object to replace.
countthe number of objects to replace.
objectthe object to insert into the gap.
Returns
A reference to this array after modification.
See also
replace(int,int,const array&)

◆ reverse()

template<typename T >
virtual void z::core::array< T >::reverse ( )
inlinevirtualnoexcept

Reverse the order of all elements in the array.

Re-Entry: Simultaneous calls to this member function on the same object can cause data races.

Reverses the array in-place, mutating existing values.

Reimplemented in z::core::sortedArray< T >, and z::core::sortedArray< zstring * >.

◆ reversed()

template<typename T >
array z::core::array< T >::reversed ( ) const
inlinenoexcept

Reverse the order of all elements in the array.

Re-Entry: This member function is thread-safe. Simultaneous calls will not cause data races, and any other thread-safe member may be called concurrently without interfering.

Creates a new, reversed version of the array, without mutating existing values.

Returns
A copy of this array, reversed.

◆ save() [1/3]

template<typename T >
template<typename archive >
void z::core::array< T >::save ( archive ar) const
inline

Binary specialization of serialization output.

Parameters
arThe output archive.

◆ save() [2/3]

template<typename T >
void z::core::array< T >::save ( cereal::JSONOutputArchive &  ar) const
inline

JSON specialization of serialization output.

Parameters
arThe output archive.

◆ save() [3/3]

template<typename T >
void z::core::array< T >::save ( cereal::XMLOutputArchive &  ar) const
inline

XML specialization of serialization output.

Parameters
arThe output archive.

◆ shuffle()

template<typename T >
virtual void z::core::array< T >::shuffle ( )
inlinevirtualnoexcept

Shuffle the elements of the array into a random order.

Re-Entry: Simultaneous calls to this member function on the same object can cause data races.

Shuffles the array in-place, mutating existing values.

Reimplemented in z::core::sortedArray< T >, and z::core::sortedArray< zstring * >.

◆ shuffled()

template<typename T >
array z::core::array< T >::shuffled ( ) const
inlinenoexcept

Shuffle the elements of the array into a random order.

Re-Entry: This member function is thread-safe. Simultaneous calls will not cause data races, and any other thread-safe member may be called concurrently without interfering.

Creates a new, shuffled version of the array, without mutating existing values.

Returns
A copy of this array, shuffled.

◆ size()

template<typename T >
size_t z::core::array< T >::size ( ) const
overridevirtualnoexcept

Get the size of the array.

Returns
The (approximate) number of bytes the array consumes.

Implements z::core::sizable.

◆ sort() [1/2]

template<typename T >
void z::core::array< T >::sort ( )
inlinenoexcept

Sort the array based on default comparison operator.

Sorts the array in-place, mutating existing values.

◆ sort() [2/2]

template<typename T >
void z::core::array< T >::sort ( std::function< bool(const T &, const T &)>  lambda)
inlinenoexcept

Sort the array based on an arbitrary function.

Sorts the array in-place, mutating existing values.

Parameters
lambdaA function that takes two elements, and returns true if the first item comes after the second (e.g. A greater than B).

◆ sorted() [1/2]

template<typename T >
array z::core::array< T >::sorted ( ) const
inlinenoexcept

Sort the array based on default comparison operator.

Creates a new, sorted version of the array, without mutating existing values.

Returns
A copy of this array, sorted.

◆ sorted() [2/2]

template<typename T >
array z::core::array< T >::sorted ( std::function< bool(const T &, const T &)>  lambda) const
inlinenoexcept

Sort the array based on an arbitrary function.

Creates a new, sorted version of the array, without mutating existing values.

Parameters
lambdaA function that takes two elements, and returns true if the first item comes after the second (e.g. A greater than B).
Returns
A copy of this array, sorted.

◆ subset()

template<typename T >
array< T > z::core::array< T >::subset ( int  index,
int  count 
) const

Get a contiguous subset of the elements in the array.

Copies all elements in the given range, inclusive. If either of the parameters is -1, gives an empty array. If the stop parameter is less than start, then the subset is copied in reverse order.

Parameters
indexthe index of the first object to copy.
countthe number of objects to copy.
Returns
A subset of the main array.

◆ swap()

template<typename T >
array< T > & z::core::array< T >::swap ( int  index1,
int  index2 
)

Swap two elements in an array.

Parameters
index1The index of the first element to swap.
index2The index of the second element to swap.
Returns
A reference to this object, to allow for method chaining.
Exceptions
std::out_of_rangeif either of the indexes is an invalid index.

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