#include <Teuchos_Array.hpp>
Public Member Functions | |
| Array () | |
| Empty constructor. | |
| Array (int n) | |
| Allocate an array with n elements. | |
| Array (int n, const T &t) | |
Allocate n elements, and fill with value t. | |
| Array< T > & | append (const T &entry) |
| Add a new entry at the end of the array. Resize to allow space for the new entry. | |
| void | remove (int i) |
| Remove the i-th element from the array, with optional boundschecking. | |
| int | length () const |
| Return number of elements in the array. Equivalent to size(), but included for backwards compatibility. | |
| T & | operator[] (int i) |
| Read/Write access to a the i-th element, with optional boundschecking. | |
| const T & | operator[] (int i) const |
| Read-only access to a the i-th element, with optional boundschecking. | |
| std::string | toString () const |
| Write Array as a std::string. | |
Static Public Member Functions | |
| static bool | hasBoundsChecking () |
| Return true if Array has been compiled with boundschecking on. | |
Related Functions | |
| (Note that these are not member functions.) | |
| std::ostream & | operator<< (std::ostream &os, const Array< T > &array) |
| Write an Array to a stream. | |
| int | hashCode (const Array< T > &array) |
| std::string | toString (const Array< T > &array) |
| Array< T > | fromStringToArray (const std::string &arrayStr) |
Converts from std::string representation (as created by toString()) back into the array object. | |
| Array< T > | tuple (const T &a) |
| Create an array with one entry. | |
| Array< T > | tuple (const T &a, const T &b) |
| Create an array with two entries. | |
| Array< T > | tuple (const T &a, const T &b, const T &c) |
| Create an array with three entries. | |
| Array< T > | tuple (const T &a, const T &b, const T &c, const T &d) |
| Create an array with four entries. | |
| Array< T > | tuple (const T &a, const T &b, const T &c, const T &d, const T &e) |
| Create an array with five entries. | |
| Array< T > | tuple (const T &a, const T &b, const T &c, const T &d, const T &e, const T &f) |
| Create an array with six entries. | |
| Array< T > | tuple (const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g) |
| Create an array with seven entries. | |
| Array< T > | tuple (const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h) |
| Create an array with eight entries. | |
| Array< T > | tuple (const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i) |
| Create an array with nine entries. | |
| Array< T > | tuple (const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i, const T &j) |
| Create an array with ten entries. | |
Definition at line 55 of file Teuchos_Array.hpp.
| Teuchos::Array< T >::Array | ( | ) | [inline] |
| Teuchos::Array< T >::Array | ( | int | n | ) | [inline] |
| Teuchos::Array< T >::Array | ( | int | n, | |
| const T & | t | |||
| ) | [inline] |
| Array<T>& Teuchos::Array< T >::append | ( | const T & | entry | ) | [inline] |
Add a new entry at the end of the array. Resize to allow space for the new entry.
Definition at line 68 of file Teuchos_Array.hpp.
| void Teuchos::Array< T >::remove | ( | int | i | ) |
Remove the i-th element from the array, with optional boundschecking.
Definition at line 122 of file Teuchos_Array.hpp.
| int Teuchos::Array< T >::length | ( | ) | const [inline] |
Return number of elements in the array. Equivalent to size(), but included for backwards compatibility.
Definition at line 76 of file Teuchos_Array.hpp.
| T & Teuchos::Array< T >::operator[] | ( | int | i | ) | [inline] |
Read/Write access to a the i-th element, with optional boundschecking.
Definition at line 131 of file Teuchos_Array.hpp.
| const T & Teuchos::Array< T >::operator[] | ( | int | i | ) | const [inline] |
Read-only access to a the i-th element, with optional boundschecking.
Definition at line 139 of file Teuchos_Array.hpp.
| std::string Teuchos::Array< T >::toString | ( | ) | const [inline] |
| bool Teuchos::Array< T >::hasBoundsChecking | ( | ) | [inline, static] |
Return true if Array has been compiled with boundschecking on.
Definition at line 147 of file Teuchos_Array.hpp.
| std::ostream & operator<< | ( | std::ostream & | os, | |
| const Array< T > & | array | |||
| ) | [related] |
| std::string toString | ( | const Array< T > & | array | ) | [related] |
Definition at line 199 of file Teuchos_Array.hpp.
| Array< T > fromStringToArray | ( | const std::string & | arrayStr | ) | [related] |
Converts from std::string representation (as created by toString()) back into the array object.
| arrayStr | [in] The std::string representation of the array (see below). |
InvalidArrayStringRepresentation with be thrown with a decent error message attached.
The formating of the std::string arrayStr must look like:
{ val[0], val[1], val[2], val[3], ..., val[n-1] }
Currently operator>>() is used to convert the entries from their std::string representation to objects of type T. White space is unimportant and the parser keys off of ',', '{' and '}' so even newlines are allowed. In the future, a traits class might be defined that will allow for finer-grained control of how the conversion from strings to values is performed in cases where operator>>() does not exist for certain types.
Warning! Currently this function only supports reading in flat array objects for basic types like bool, int, and double and does not yet support nested arrays (i.e. no Array<Array<int> >) or other such fancy nested types. Support for nested arrays and other user defined types T can be added in the future with no impact on user code. Only the parser for the array needs to be improved. More specifically, the current implementation will not work for any types T who's std::string representation contains the characters ',' or '}'. This implementation can be modified to allow any such types by watching for the nesting of common enclosing structures like [...], {...} or (...) within each entry of the std::string representation. However, this should all just work fine on most machines for the types int, bool, float, double etc.
Warning! Trying to read in an array in std::string format of doubles in scientific notation such as {1e+2,3.53+6,...} into an array object such as Array<int> will not yield the correct results. If one wants to allow a neutral std::string representation to be read in as an Array<double> object or an Array<int> object, then general formating such as {100,3530000,...} should be used. This templated function is unable to deal std::complex type conversion issues.
Definition at line 256 of file Teuchos_Array.hpp.
| Array< T > tuple | ( | const T & | a | ) | [related] |
| Array< T > tuple | ( | const T & | a, | |
| const T & | b | |||
| ) | [related] |
| Array< T > tuple | ( | const T & | a, | |
| const T & | b, | |||
| const T & | c | |||
| ) | [related] |
| Array< T > tuple | ( | const T & | a, | |
| const T & | b, | |||
| const T & | c, | |||
| const T & | d | |||
| ) | [related] |
| Array< T > tuple | ( | const T & | a, | |
| const T & | b, | |||
| const T & | c, | |||
| const T & | d, | |||
| const T & | e | |||
| ) | [related] |
| Array< T > tuple | ( | const T & | a, | |
| const T & | b, | |||
| const T & | c, | |||
| const T & | d, | |||
| const T & | e, | |||
| const T & | f | |||
| ) | [related] |
| Array< T > tuple | ( | const T & | a, | |
| const T & | b, | |||
| const T & | c, | |||
| const T & | d, | |||
| const T & | e, | |||
| const T & | f, | |||
| const T & | g | |||
| ) | [related] |
| Array< T > tuple | ( | const T & | a, | |
| const T & | b, | |||
| const T & | c, | |||
| const T & | d, | |||
| const T & | e, | |||
| const T & | f, | |||
| const T & | g, | |||
| const T & | h | |||
| ) | [related] |
| Array< T > tuple | ( | const T & | a, | |
| const T & | b, | |||
| const T & | c, | |||
| const T & | d, | |||
| const T & | e, | |||
| const T & | f, | |||
| const T & | g, | |||
| const T & | h, | |||
| const T & | i | |||
| ) | [related] |
| Array< T > tuple | ( | const T & | a, | |
| const T & | b, | |||
| const T & | c, | |||
| const T & | d, | |||
| const T & | e, | |||
| const T & | f, | |||
| const T & | g, | |||
| const T & | h, | |||
| const T & | i, | |||
| const T & | j | |||
| ) | [related] |
1.4.7