|
| Array () |
| default constructor More...
|
|
| Array (Array< T > &&other) |
| move constructor More...
|
|
| Array (const Array< T > &other) |
| copy constructor More...
|
|
| Array (ObjectPtr< Object > n) |
| constructor from pointer More...
|
|
template<typename IterType > |
| Array (IterType first, IterType last) |
| Constructor from iterator. More...
|
|
| Array (std::initializer_list< T > init) |
| constructor from initializer list More...
|
|
| Array (const std::vector< T > &init) |
| constructor from vector More...
|
|
| Array (const size_t n, const T &val) |
| Constructs a container with n elements. Each element is a copy of val. More...
|
|
Array< T > & | operator= (Array< T > &&other) |
| move assign operator More...
|
|
Array< T > & | operator= (const Array< T > &other) |
| copy assign operator More...
|
|
iterator | begin () const |
|
iterator | end () const |
|
reverse_iterator | rbegin () const |
|
reverse_iterator | rend () const |
|
const T | operator[] (int64_t i) const |
| Immutably read i-th element from array. More...
|
|
size_t | size () const |
|
size_t | capacity () const |
|
bool | empty () const |
|
const T | front () const |
|
const T | back () const |
|
void | push_back (const T &item) |
| push a new item to the back of the list More...
|
|
void | insert (iterator position, const T &val) |
| Insert an element into the given position. More...
|
|
template<typename IterType > |
void | insert (iterator position, IterType first, IterType last) |
| Insert a range of elements into the given position. More...
|
|
void | pop_back () |
| Remove the last item of the list. More...
|
|
void | erase (iterator position) |
| Erase an element on the given position. More...
|
|
void | erase (iterator first, iterator last) |
| Erase a given range of elements. More...
|
|
void | resize (int64_t n) |
| Resize the array. More...
|
|
void | reserve (int64_t n) |
| Make sure the list has the capacity of at least n. More...
|
|
void | clear () |
| Release reference to all the elements. More...
|
|
void | Set (int64_t i, T value) |
| set i-th element of the array. More...
|
|
ArrayNode * | GetArrayNode () const |
|
template<typename F , typename U = std::invoke_result_t<F, T>> |
Array< U > | Map (F fmap) const |
| Helper function to apply a map function onto the array. More...
|
|
template<typename F , typename = std::enable_if_t<std::is_same_v<T, std::invoke_result_t<F, T>>>> |
void | MutateByApply (F fmutate) |
| Helper function to apply fmutate to mutate an array. More...
|
|
template<typename IterType > |
void | Assign (IterType first, IterType last) |
| reset the array to content from iterator. More...
|
|
ArrayNode * | CopyOnWrite () |
| Copy on write semantics Do nothing if current handle is the unique copy of the array. Otherwise make a new copy of the array to ensure the current handle hold a unique copy. More...
|
|
| ObjectRef ()=default |
| default constructor More...
|
|
| ObjectRef (ObjectPtr< Object > data) |
| Constructor from existing object ptr. More...
|
|
bool | same_as (const ObjectRef &other) const |
| Comparator. More...
|
|
bool | operator== (const ObjectRef &other) const |
| Comparator. More...
|
|
bool | operator!= (const ObjectRef &other) const |
| Comparator. More...
|
|
bool | operator< (const ObjectRef &other) const |
| Comparator. More...
|
|
bool | defined () const |
|
const Object * | get () const |
|
const Object * | operator-> () const |
|
bool | unique () const |
|
int | use_count () const |
|
template<typename ObjectType > |
const ObjectType * | as () const |
| Try to downcast the internal Object to a raw pointer of a corresponding type. More...
|
|
template<typename T, typename = typename std::enable_if<std::is_base_of<ObjectRef, T>::value>::type>
class tvm::runtime::Array< T, typename >
Array, container representing a contiguous sequence of ObjectRefs.
Array implements in-place copy-on-write semantics.
As in typical copy-on-write, a method which would typically mutate the array instead opaquely copies the underlying container, and then acts on its copy.
If the array has reference count equal to one, we directly update the container in place without copying. This is optimization is sound because when the reference count is equal to one this reference is guranteed to be the sole pointer to the container.
operator[] only provides const access, use Set to mutate the content.
- Template Parameters
-
template<typename T, typename = typename std::enable_if<std::is_base_of<ObjectRef, T>::value>::type>
template<typename F , typename = std::enable_if_t<std::is_same_v<T, std::invoke_result_t<F, T>>>>
Helper function to apply fmutate to mutate an array.
- Parameters
-
fmutate | The transformation function T -> T. |
- Template Parameters
-
F | the type of the mutation function. |
- Note
- This function performs copy on write optimization.