|
CoreComponents 3.0.0
A Modern C++ Toolkit
|
An array of items within a contiguous chunk of memory. More...
#include <cc/Array>
Public Types | |
| using | Item = T |
| Item type. | |
Standard Iterators | |
| using | value_type = Item |
| Item value type. | |
| using | size_type = long |
| Type of the container capacity. | |
| using | iterator = ArrayIterator<Array, 1> |
| Value iterator. | |
| using | const_iterator = ArrayIterator<const Array, 1> |
| Readonly value iterator. | |
| using | reverse_iterator = ArrayIterator<Array, -1> |
| Reverse value iterator. | |
| using | const_reverse_iterator = ArrayIterator<const Array, -1> |
| Readonly reverse value iterator. | |
| iterator | begin () |
| Return iterator pointing to the first item (if any) | |
| iterator | end () |
| Return iterator pointing behind the last item | |
| const_iterator | begin () const |
| Return readonly iterator pointing to the first item (if any) | |
| const_iterator | cbegin () const |
| Return readonly iterator pointing to the first item (if any) | |
| const_iterator | end () const |
| Return readonly iterator pointing behind the last item | |
| const_iterator | cend () const |
| Return readonly iterator pointing behind the last item | |
| reverse_iterator | rbegin () |
| Return reverse iterator pointing to the last item (if any) | |
| reverse_iterator | rend () |
| Return reverse iterator pointing before the first item | |
| const_reverse_iterator | rbegin () const |
| Return readonly reverse iterator pointing to the last item (if any) | |
| const_reverse_iterator | crbegin () const |
| Return readonly reverse iterator pointing to the last item (if any) | |
| const_reverse_iterator | rend () const |
| Return reverse iterator pointing before the first item | |
| const_reverse_iterator | crend () const |
| Return reverse iterator pointing before the first item | |
Construction and Assignment | |
| static Array | allocate (long n) |
| Create a array of n items. | |
| Array () | |
| Create an empty array. | |
| Array (Dim< 1 > dim) | |
| Create a array of dim[0] items. | |
| Array (const Array &other)=default | |
| Construct a copy of other. | |
| Array (Array &&b) | |
| Construct from right-side b. | |
| Array (std::initializer_list< T > items) | |
| Construct with initial items. | |
| Array (std::initializer_list< Array > arrays) | |
| Concatenate arrays into a single new array. | |
| Array (const Item *src, long count) | |
| Create a copy of the low-level array src of count items. | |
| Array (const List< Array > &parts) | |
| Join several arrays into one. | |
| Array (const List< Array > &parts, Item sep) | |
| Join several arrays into one using sep as interposing separator. | |
| Array & | operator= (const Array &)=default |
| Default assignment operator. | |
| Array & | operator= (Array &&b) |
| Assign right-side b. | |
Type Compatibility | |
| static Array | wrap (void *data, long count) |
| Create a new array wrapped around data containing count items. | |
| const Item * | items () const |
| Get pointer to internal memory buffer. | |
| Item * | items () |
| Get pointer to internal memory buffer. | |
| const char * | chars () const |
| Low-level access to the underlying characters. | |
| char * | chars () |
| Low-level access to the underlying characters. | |
| const uint8_t * | bytes () const |
| Low-level access to the underlying bytes. | |
| uint8_t * | bytes () |
| Low-level access to the underlying bytes. | |
| const uint32_t * | words () const |
| Low-level access to the underlying memory words. | |
| uint32_t * | words () |
| Low-level access to the underlying memory words. | |
| template<class OtherItem > | |
| operator OtherItem * () | |
| Explicit conversion to low-level pointer. | |
| template<class OtherItem > | |
| operator const OtherItem * () const | |
| Explicit conversion to constant low-level pointer. | |
| operator void * () | |
| Implicit conversion to low-level data pointer. | |
| operator const void * () const | |
| Implicit conversion to constant low-level data pointer. | |
| void | wrapAround (void *data, long count) |
| Wrap this array around the low-level memory vector data of count items. | |
Item Access | |
| long | count () const |
| Size of this array in number of items. | |
| long | size () const |
| Size of this array in number of items. | |
| bool | has (long i) const |
| Check if i is a valid index. | |
| operator bool () const | |
| Check if this array is non-empty. | |
| long | operator+ () const |
| Size of this array in number of items. | |
| Item & | at (long i) |
| Get a reference to the item at i. | |
| const Item & | at (long i) const |
| Get a constant reference to the item at i. | |
| template<class U > | |
| long | itemCount () const |
| Get number of items of type U. | |
| template<class U > | |
| U & | item (long j) |
| Return a reference to an object of type U at object index j | |
| template<class U > | |
| const U & | item (long j) const |
| Return a constant reference to an object of type U at object index j | |
| std::uint8_t & | byteAt (long j) |
| Convenience function for item<std::uint8_t>() | |
| const std::uint8_t & | byteAt (long j) const |
| Convenience function for item<std::uint8_t>() | |
| std::uint32_t & | wordAt (long j) |
| Convenience function for item<std::uint32_t>() | |
| const std::uint32_t & | wordAt (long j) const |
| Convenience function for item<std::uint32_t>() | |
| Item & | operator[] (long i) |
| Get a reference to the item at i. | |
| const Item & | operator[] (long i) const |
| Get a constant reference to the item at i. | |
| Item | operator() (long i) const |
| Get value at index if 0 <= i && i < count(), otherwise return fallback. | |
| Array & | operator() (long i, const T &value) |
| Set value at index if 0 <= i && i < count(), otherwise do nothing. | |
| const Item & | first () const |
| Get constant reference to first item. | |
| const Item & | last () const |
| Get constant reference to last item. | |
| bool | startsWith (const Array &head) const |
| Check if head equals the start of this array. | |
| bool | endsWith (const Array &tail) const |
| Check if tail equals the end of this array. | |
Global Operations | |
| long | count (const Item &b) const |
| Count the number of occurences of item b. | |
| bool | find (const Item &b, InOut< long > i0=None{}) const |
| Find item b. | |
| void | replace (const Item &b, const Item &s) |
| Replace all occurance of b by s. | |
| Array | copy () const |
| Create a deep copy of this array. | |
| Array | copy (long i0, long i1) const |
| Create a copy of range [i0, i1) | |
| void | copyRangeTo (long i0, long i1, Out< Array > dst) const |
| Copy the items in range [i0, i1] to array dst. | |
| void | copyRangeToOffset (long i0, long i1, Out< Array > dst, long j0) const |
| Copy the items in range [i0, i1] to array dst starting at item dst[j0]. | |
| void | copyTo (Out< Array > dst) const |
| Copy contents of this array to array dst. | |
| void | copyToOffset (Out< Array > dst, long j0) const |
| Copy contents of this array to array dst starting at item dst[j0]. | |
| void | copyToRange (Out< Array > dst, long j0, long j1) const |
| Copy contents of this array to array dst in the range dst[j0]..dst[j1-1]. | |
| template<class F > | |
| void | applyTo (InOut< Array > dst) const |
| Apply the contents of this array to array dst. | |
| void | fill (const Item &b) |
| Set all items to b | |
| void | resize (long n) |
| Resize this array to n items preserving the contents (new items are uninitialized) | |
| void | truncate (long n) |
| Reduce the length of this array to n items without freeing memory. | |
| void | deplete () |
| Truncate to zero length and free all previously stored items. | |
| Array | select (long i0, long i1) |
| Return a selection of range [i0, i1) | |
| Array & | selectAs (long i0, long i1, Out< Array > target) |
| Return a selection of range [i0, i1) in target | |
| Array | selectHead (long n) |
| Select the first n items or less (if n > count()) | |
| Array | selectTail (long n) |
| Select the last n items or less (if n > count()) | |
| long | offset () const |
| Offset of this array within its parent array if this array is a selection (0 otherwise) | |
| Array | parent () |
| Get parent array if this array is a selection. | |
| void | shift (long n) |
| Truncate |n| items from the front (n > 0) or from the back (n < 0) | |
| void | reverse () |
| Reverse the order of items in this array. | |
| Array | reversed () const |
| Get a copy of this array with order of items reversed. | |
Comparism Operators | |
| bool | operator== (const Array &other) const |
| Equality operator. | |
| std::strong_ordering | operator<=> (const Array &other) const |
| Ordering operator. | |
An array of items within a contiguous chunk of memory.
| T | Item type |
| using Item = T |
Item type.
| using value_type = Item |
Item value type.
| using size_type = long |
Type of the container capacity.
| using iterator = ArrayIterator<Array, 1> |
Value iterator.
| using const_iterator = ArrayIterator<const Array, 1> |
Readonly value iterator.
| using reverse_iterator = ArrayIterator<Array, -1> |
Reverse value iterator.
| using const_reverse_iterator = ArrayIterator<const Array, -1> |
Readonly reverse value iterator.
| Array | ( | ) |
Create an empty array.
Create a array of dim[0] items.
| Array | ( | std::initializer_list< T > | items | ) |
Construct with initial items.
Concatenate arrays into a single new array.
Create a copy of the low-level array src of count items.
Join several arrays into one using sep as interposing separator.
|
static |
Create a array of n items.
| long count | ( | ) | const |
Size of this array in number of items.
| long size | ( | ) | const |
Size of this array in number of items.
| bool has | ( | long | i | ) | const |
Check if i is a valid index.
|
explicit |
Check if this array is non-empty.
| long operator+ | ( | ) | const |
Size of this array in number of items.
| Item & at | ( | long | i | ) |
Get a reference to the item at i.
| const Item & at | ( | long | i | ) | const |
Get a constant reference to the item at i.
| long itemCount | ( | ) | const |
Get number of items of type U.
| U & item | ( | long | j | ) |
Return a reference to an object of type U at object index j
| const U & item | ( | long | j | ) | const |
Return a constant reference to an object of type U at object index j
| std::uint8_t & byteAt | ( | long | j | ) |
Convenience function for item<std::uint8_t>()
| const std::uint8_t & byteAt | ( | long | j | ) | const |
Convenience function for item<std::uint8_t>()
| std::uint32_t & wordAt | ( | long | j | ) |
Convenience function for item<std::uint32_t>()
| const std::uint32_t & wordAt | ( | long | j | ) | const |
Convenience function for item<std::uint32_t>()
| Item & operator[] | ( | long | i | ) |
Get a reference to the item at i.
| const Item & operator[] | ( | long | i | ) | const |
Get a constant reference to the item at i.
| Item operator() | ( | long | i | ) | const |
Get value at index if 0 <= i && i < count(), otherwise return fallback.
| Array & operator() | ( | long | i, |
| const T & | value ) |
| const Item & first | ( | ) | const |
Get constant reference to first item.
| const Item & last | ( | ) | const |
Get constant reference to last item.
| bool startsWith | ( | const Array< T > & | head | ) | const |
Check if head equals the start of this array.
| bool endsWith | ( | const Array< T > & | tail | ) | const |
Check if tail equals the end of this array.
| long count | ( | const Item & | b | ) | const |
Count the number of occurences of item b.
Find item b.
| b | The item to search for |
| i0 | Provides the starting position and returns the final position |
| Array copy | ( | ) | const |
Create a deep copy of this array.
| Array copy | ( | long | i0, |
| long | i1 ) const |
Create a copy of range [i0, i1)
Copy the items in range [i0, i1] to array dst.
| void copyRangeToOffset | ( | long | i0, |
| long | i1, | ||
| Out< Array< T > > | dst, | ||
| long | j0 ) const |
Copy the items in range [i0, i1] to array dst starting at item dst[j0].
Copy contents of this array to array dst.
Copy contents of this array to array dst starting at item dst[j0].
Copy contents of this array to array dst in the range dst[j0]..dst[j1-1].
Apply the contents of this array to array dst.
| F | Application policy (e.g. Xor) |
| void fill | ( | const Item & | b | ) |
Set all items to b
| void resize | ( | long | n | ) |
Resize this array to n items preserving the contents (new items are uninitialized)
| void truncate | ( | long | n | ) |
Reduce the length of this array to n items without freeing memory.
| void deplete | ( | ) |
Truncate to zero length and free all previously stored items.
| Array select | ( | long | i0, |
| long | i1 ) |
Return a selection of range [i0, i1)
Return a selection of range [i0, i1) in target
| long offset | ( | ) | const |
Offset of this array within its parent array if this array is a selection (0 otherwise)
| Array parent | ( | ) |
Get parent array if this array is a selection.
| void shift | ( | long | n | ) |
Truncate |n| items from the front (n > 0) or from the back (n < 0)
| void reverse | ( | ) |
Reverse the order of items in this array.
| Array reversed | ( | ) | const |
Get a copy of this array with order of items reversed.
| const Item * items | ( | ) | const |
Get pointer to internal memory buffer.
| Item * items | ( | ) |
Get pointer to internal memory buffer.
| const char * chars | ( | ) | const |
Low-level access to the underlying characters.
| char * chars | ( | ) |
Low-level access to the underlying characters.
| const uint8_t * bytes | ( | ) | const |
Low-level access to the underlying bytes.
| uint8_t * bytes | ( | ) |
Low-level access to the underlying bytes.
| const uint32_t * words | ( | ) | const |
Low-level access to the underlying memory words.
| uint32_t * words | ( | ) |
Low-level access to the underlying memory words.
|
explicit |
Explicit conversion to low-level pointer.
|
explicit |
Explicit conversion to constant low-level pointer.
| operator void * | ( | ) |
Implicit conversion to low-level data pointer.
| operator const void * | ( | ) | const |
Implicit conversion to constant low-level data pointer.
| void wrapAround | ( | void * | data, |
| long | count ) |
Wrap this array around the low-level memory vector data of count items.
|
static |
Create a new array wrapped around data containing count items.
| iterator begin | ( | ) |
Return iterator pointing to the first item (if any)
| iterator end | ( | ) |
Return iterator pointing behind the last item
| const_iterator begin | ( | ) | const |
Return readonly iterator pointing to the first item (if any)
| const_iterator cbegin | ( | ) | const |
Return readonly iterator pointing to the first item (if any)
| const_iterator end | ( | ) | const |
Return readonly iterator pointing behind the last item
| const_iterator cend | ( | ) | const |
Return readonly iterator pointing behind the last item
| reverse_iterator rbegin | ( | ) |
Return reverse iterator pointing to the last item (if any)
| reverse_iterator rend | ( | ) |
Return reverse iterator pointing before the first item
| const_reverse_iterator rbegin | ( | ) | const |
Return readonly reverse iterator pointing to the last item (if any)
| const_reverse_iterator crbegin | ( | ) | const |
Return readonly reverse iterator pointing to the last item (if any)
| const_reverse_iterator rend | ( | ) | const |
Return reverse iterator pointing before the first item
| const_reverse_iterator crend | ( | ) | const |
Return reverse iterator pointing before the first item
| bool operator== | ( | const Array< T > & | other | ) | const |
Equality operator.
| std::strong_ordering operator<=> | ( | const Array< T > & | other | ) | const |
Ordering operator.