|
|
Constructors here are limited to those that don't allocate new data, and can only accept const data to reference.
Copy assignment is suppressed.
|
| ArrayViewConst_ () |
| Default constructor allocates no heap space and is very fast. More...
|
|
| ArrayViewConst_ (const ArrayViewConst_ &src) |
| Copy constructor is shallow; the constructed const array object will be referencing the original source data. More...
|
|
| ArrayViewConst_ (const T *first, const T *last1) |
| Construct an ArrayViewConst_<T> by referencing (sharing) a given range of const data [first,last1), without copying that data. More...
|
|
template<class A > |
| ArrayViewConst_ (const std::vector< T, A > &src) |
| Construct a ArrayViewConst_<T> by referencing (sharing) the data in a const std::vector<T>, without copying the data; this is also an implicit conversion. More...
|
|
| operator const ArrayView_< T, X > & () const |
| This is an implicit conversion to const ArrayView_<T,X>&, which is harmless since the const result won't permit writing on the elements. More...
|
|
| operator const Array_< T, X > & () const |
| This is an implicit conversion to const Array_<T,X>&, which is harmless since the const result can't be used to write on or resize the data. More...
|
|
void | disconnect () |
| Disconnect this array handle from any data to which it refers, restoring it to the condition it would be in if it had just been default-constructed. More...
|
|
| ~ArrayViewConst_ () |
| The destructor just disconnects the array view handle from its data; see disconnect() for more information. More...
|
|
|
These methods examine the number of elements (size) or the amount of allocated heap space (capacity).
See the derived Array_<T,X> class for methods that can change the size or capacity.
|
size_type | size () const |
| Return the current number of elements stored in this array. More...
|
|
size_type | max_size () const |
| Return the maximum allowable size for this array. More...
|
|
bool | empty () const |
| Return true if there are no elements currently stored in this array. More...
|
|
size_type | capacity () const |
| Return the number of elements this array can currently hold without requiring reallocation. More...
|
|
size_type | allocated () const |
| Return the amount of heap space owned by this array; this is the same as capacity() for owner arrays but is zero for non-owners. More...
|
|
bool | isOwner () const |
| Does this array own the data to which it refers? If not, it can't be resized, and the destructor will not free any heap space nor call any element destructors. More...
|
|
|
These methods provide read-only (const) access to individual elements that are currently present in the array.
The derived ArrayView_<T,X> class adds the non-const versions of these methods.
|
const T & | operator[] (index_type i) const |
| Select an element by its index, returning a const reference. More...
|
|
const T & | at (index_type i) const |
| Same as operator[] but always range-checked, even in a Release build. More...
|
|
const T & | getElt (index_type i) const |
| Same as the const form of operator[]; exists to provide a non-operator method for element access in case that's needed. More...
|
|
const T & | front () const |
| Return a const reference to the first element in this array, which must not be empty (we'll check in a Debug build but not Release). More...
|
|
const T & | back () const |
| Return a const reference to the last element in this array, which must not be empty (we'll check in a Debug build but not Release). More...
|
|
ArrayViewConst_ | operator() (index_type index, size_type length) const |
| Select a contiguous subarray of the elements of this array and create another ArrayViewConst_ that refers only to those element (without copying). More...
|
|
ArrayViewConst_ | getSubArray (index_type index, size_type length) const |
| Same as const form of operator()(index,length); exists to provide non-operator access to that functionality in case it is needed. More...
|
|
|
These methods deal in iterators, which are STL generalized pointers.
For this class, iterators are just ordinary const pointers to T, and you may depend on that. By necessity, reverse iterators can't be just pointers; however, they contain an ordinary iterator (i.e. a pointer) that can be obtained by calling the reverse iterator's base() method.
|
const T * | cbegin () const |
| Return a const pointer to the first element of this array if any, otherwise cend(), which may be null (0) in that case but does not have to be. More...
|
|
const T * | cend () const |
| Return a const pointer to what would be the element just after the last one in the array; this may be null (0) if there are no elements but doesn't have to be. More...
|
|
const T * | begin () const |
| The const version of begin() is the same as cbegin(). More...
|
|
const T * | end () const |
| The const version of end() is the same as cend(). More...
|
|
const_reverse_iterator | crbegin () const |
| Return a const reverse iterator pointing to the last element in the array or crend() if the array is empty. More...
|
|
const_reverse_iterator | crend () const |
| Return the past-the-end reverse iterator that tests equal to a reverse iterator that has been incremented past the front of the array. More...
|
|
const_reverse_iterator | rbegin () const |
| The const version of rbegin() is the same as crbegin(). More...
|
|
const_reverse_iterator | rend () const |
| The const version of rend() is the same as crend(). More...
|
|
const T * | cdata () const |
| Return a const pointer to the first element of the array, or possibly (but not necessarily) null (0) if the array is empty. More...
|
|
const T * | data () const |
| The const version of the data() method is identical to cdata(). More...
|
|
template<class T, class X>
class SimTK::ArrayViewConst_< T, X >
This Array_ helper class is the base class for ArrayView_ which is the base class for Array_; here we provide only the minimal read-only "const" functionality required by any Array_ object, and shallow copy semantics.
The ability to write is added by the ArrayView_ class, and the additional ability to reallocate, insert, erase, etc. is added by the Array_ class.
This class is particularly useful for recasting existing const data into a const Array_ without copying. For example a const std::vector can be passed to a const Array& argument by an implicit, near-zero cost conversion to an ArrayViewConst_ which can then convert to a const Array&.
An ArrayViewConst_ is given all the data it is going to have at the time it is constructed (except when it is being accessed from the derived Array_ class that has more capability). The contents and size of a ArrayViewConst_ cannot be changed after construction. In particular, the default copy assignment operator is suppressed. The destructor simply disconnects the ArrayViewConst_ handle from the data it was referencing; no element destruction or heap deallocation occurs.
- Template Parameters
-
T | The type of object to be stored in this container. |
X | The type to be used for indexing this container, with default unsigned (not size_t). Any integral type may be used, as well as user types that satisfy the requirements discussed with class ArrayIndexTraits. |
- See also
- Array_, ArrayView_, ArrayIndexTraits
template<class T, class X>
Construct an ArrayViewConst_<T> by referencing (sharing) a given range of const data [first,last1), without copying that data.
This will work as long as the size of the source data does not exceed the array's max_size. The resulting object is not resizeable but can be used to read elements of the original data. This will becomes invalid if the original data is destructed or resized, but there is no way for the ArrayViewConst_ class to detect that.
- Parameters
-
[in] | first | A pointer to the first data element to be referenced. |
[in] | last1 | A pointer to the position one element past the last one in the range to be referenced. |
- Precondition
- first <= last1, last1-first <= max_size()
- Complexity:
- Dirt cheap. There will be no construction, destruction, or heap allocation performed.
- See also
- disconnect()
template<class T, class X>
template<class A >
Construct a ArrayViewConst_<T> by referencing (sharing) the data in a const std::vector<T>, without copying the data; this is also an implicit conversion.
This will work as long as the size of the vector does not exceed the array's max_size. The resulting array object is not resizeable but can be used to read elements of the original std::vector. The array becomes invalid if the original std::vector is destructed or resized, but there is no way for the array class to detect that.
- Parameters
-
[in] | src | The std::vector<T> whose data will be referenced by the constructed ArrayViewConst_ handle. |
- Precondition
- src.size() <= max_size()
- Complexity:
- Dirt cheap. There will be no construction, destruction, or heap allocation performed.
- See also
- disconnect()