Template Class MutableArrayRef

Inheritance Relationships

Base Type

Derived Type

Class Documentation

template<typename T>
class MutableArrayRef : public ams::ArrayRef<T>

MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memory), i.e. a start pointer and a length. It allows various APIs to take and modify consecutive elements easily and conveniently.

This class does not own the underlying data, it is expected to be used in situations where the data resides in some other buffer, whose lifetime extends past that of the MutableArrayRef. For this reason, it is not in general safe to store a MutableArrayRef.

This is intended to be trivially copyable, so it should be passed by value.

Subclassed by ams::OwningArrayRef< T >

Operator Overloads

inline T &operator[](size_t Index) const

Public Types

using value_type = T
using pointer = value_type*
using const_pointer = const value_type*
using reference = value_type&
using const_reference = const value_type&
using iterator = pointer
using const_iterator = const_pointer
using reverse_iterator = std::reverse_iterator<iterator>
using const_reverse_iterator = std::reverse_iterator<const_iterator>
using size_type = size_t
using difference_type = ptrdiff_t

Public Functions

MutableArrayRef() = default

Construct an empty MutableArrayRef.

inline MutableArrayRef(T &OneElt)

Construct a MutableArrayRef from a single element.

inline MutableArrayRef(T *data, size_t length)

Construct a MutableArrayRef from a pointer and length.

inline MutableArrayRef(T *begin, T *end)

Construct a MutableArrayRef from a range.

inline MutableArrayRef(SmallVectorImpl<T> &Vec)

Construct a MutableArrayRef from a SmallVector.

inline MutableArrayRef(std::vector<T> &Vec)

Construct a MutableArrayRef from a std::vector.

template<size_t N>
inline constexpr MutableArrayRef(std::array<T, N> &Arr)

Construct a MutableArrayRef from a std::array.

template<size_t N>
inline constexpr MutableArrayRef(T (&Arr)[N])

Construct a MutableArrayRef from a C array.

inline T *data() const
inline iterator begin() const
inline iterator end() const
inline reverse_iterator rbegin() const
inline reverse_iterator rend() const
inline T &front() const

front - Get the first element.

inline T &back() const

back - Get the last element.

inline MutableArrayRef<T> slice(size_t N, size_t M) const

slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.

inline MutableArrayRef<T> slice(size_t N) const

slice(n) - Chop off the first N elements of the array.

inline MutableArrayRef<T> drop_front(size_t N = 1) const

Drop the first N elements of the array.

inline MutableArrayRef<T> drop_back(size_t N = 1) const
template<class PredicateT>
inline MutableArrayRef<T> drop_while(PredicateT Pred) const

Return a copy of *this with the first N elements satisfying the given predicate removed.

template<class PredicateT>
inline MutableArrayRef<T> drop_until(PredicateT Pred) const

Return a copy of *this with the first N elements not satisfying the given predicate removed.

inline MutableArrayRef<T> take_front(size_t N = 1) const

Return a copy of *this with only the first N elements.

inline MutableArrayRef<T> take_back(size_t N = 1) const

Return a copy of *this with only the last N elements.

template<class PredicateT>
inline MutableArrayRef<T> take_while(PredicateT Pred) const

Return the first N elements of this Array that satisfy the given predicate.

template<class PredicateT>
inline MutableArrayRef<T> take_until(PredicateT Pred) const

Return the first N elements of this Array that don’t satisfy the given predicate.