10 #ifndef LLVM_ADT_ARRAYREF_H 11 #define LLVM_ADT_ARRAYREF_H 22 #include <initializer_list> 25 #include <type_traits> 51 const T *
Data =
nullptr;
68 : Data(&OneElt), Length(1) {}
72 : Data(data), Length(length) {}
76 : Data(begin), Length(end - begin) {}
83 : Data(Vec.data()), Length(Vec.
size()) {
89 : Data(Vec.data()), Length(Vec.
size()) {}
93 constexpr
ArrayRef(
const std::array<T, N> &Arr)
94 : Data(Arr.data()), Length(
N) {}
98 constexpr
ArrayRef(
const T (&Arr)[
N]) : Data(Arr), Length(N) {}
103 Length(Vec.
size()) {}
107 template <
typename U>
110 typename std::enable_if<
111 std::is_convertible<U *const *, T const *>::value>::
type * =
nullptr)
112 : Data(A.data()), Length(A.
size()) {}
117 template<
typename U,
typename DummyT>
120 typename std::enable_if<
121 std::is_convertible<U *const *, T const *>::value>::
type * =
nullptr)
122 : Data(Vec.data()), Length(Vec.
size()) {
127 template<
typename U,
typename A>
129 typename std::enable_if<
130 std::is_convertible<U *const *, T const *>::value>::
type* = 0)
131 : Data(Vec.data()), Length(Vec.
size()) {}
144 bool empty()
const {
return Length == 0; }
149 size_t size()
const {
return Length; }
160 return Data[Length-1];
165 T *Buff = A.template Allocate<T>(Length);
166 std::uninitialized_copy(
begin(),
end(), Buff);
172 if (Length != RHS.Length)
189 assert(
size() >=
N &&
"Dropping more elements than exist");
190 return slice(
N,
size() -
N);
195 assert(
size() >=
N &&
"Dropping more elements than exist");
196 return slice(0,
size() -
N);
215 return drop_back(
size() -
N);
222 return drop_front(
size() -
N);
241 assert(Index < Length &&
"Invalid index!");
249 template <
typename U>
251 operator=(U &&Temporary) =
delete;
257 template <
typename U>
259 operator=(std::initializer_list<U>) =
delete;
264 std::vector<T>
vec()
const {
265 return std::vector<T>(
Data, Data+Length);
271 operator std::vector<T>()
const {
272 return std::vector<T>(
Data, Data+Length);
346 return data()[this->
size()-1];
352 assert(N + M <= this->
size() &&
"Invalid specifier");
358 return slice(N, this->
size() - N);
363 assert(this->
size() >=
N &&
"Dropping more elements than exist");
364 return slice(
N, this->
size() -
N);
368 assert(this->
size() >=
N &&
"Dropping more elements than exist");
369 return slice(0, this->
size() -
N);
374 template <
class PredicateT>
381 template <
class PredicateT>
388 if (
N >= this->
size())
390 return drop_back(this->
size() -
N);
395 if (
N >= this->
size())
397 return drop_front(this->
size() -
N);
402 template <
class PredicateT>
409 template <
class PredicateT>
418 assert(Index < this->
size() &&
"Invalid index!");
419 return data()[
Index];
437 delete[] this->data();
468 template <
typename T>
474 template <
typename T,
unsigned N>
496 template<
typename T,
size_t N>
524 return !(LHS == RHS);
532 static const bool value =
true;
541 #endif // LLVM_ADT_ARRAYREF_H reverse_iterator rbegin() const
const T & operator[](size_t Index) const
const T & front() const
front - Get the first element.
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...
ArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
const_iterator end(StringRef path)
Get end iterator over path.
ArrayRef< T > take_until(PredicateT Pred) const
Return the first N elements of this Array that don't satisfy the given predicate. ...
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
const T & back() const
back - Get the last element.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
MutableArrayRef< T > makeMutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
This class represents lattice values for constants.
NoneType
A simple null object to allow implicit construction of Optional<T> and similar types without having t...
constexpr MutableArrayRef(T(&Arr)[N])
Construct an MutableArrayRef from a C array.
reverse_iterator rbegin() const
ArrayRef(NoneType)
Construct an empty ArrayRef from None.
T & front() const
front - Get the first element.
ArrayRef(const std::vector< U *, A > &Vec, typename std::enable_if< std::is_convertible< U *const *, T const *>::value >::type *=0)
Construct an ArrayRef<const T*> from std::vector<T*>.
std::reverse_iterator< iterator > reverse_iterator
MutableArrayRef(std::vector< T > &Vec)
Construct a MutableArrayRef from a std::vector.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
ArrayRef< T > drop_while(PredicateT Pred) const
Return a copy of *this with the first N elements satisfying the given predicate removed.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
ArrayRef(const std::vector< T, A > &Vec)
Construct an ArrayRef from a std::vector.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
ArrayRef(const std::initializer_list< T > &Vec)
Construct an ArrayRef from a std::initializer_list.
T & operator[](size_t Index) const
ArrayRef< T > copy(Allocator &A)
MutableArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
OwningArrayRef & operator=(OwningArrayRef &&Other)
MutableArrayRef< T > take_until(PredicateT Pred) const
Return the first N elements of this Array that don't satisfy the given predicate. ...
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
ArrayRef(const SmallVectorTemplateCommon< T, U > &Vec)
Construct an ArrayRef from a SmallVector.
MutableArrayRef(T *begin, T *end)
Construct an MutableArrayRef from a range.
size_t size() const
size - Get the array size.
std::enable_if< std::is_same< U, T >::value, ArrayRef< T > >::type & operator=(U &&Temporary)=delete
Disallow accidental assignment from a temporary.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
auto find_if_not(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
MutableArrayRef< T > drop_back(size_t N=1) const
OwningArrayRef(OwningArrayRef &&Other)
This is a MutableArrayRef that owns its array.
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
ArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
isPodLike - This is a type trait that is used to determine whether a given type can be copied around ...
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
reverse_iterator rend() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
MutableArrayRef(T *data, size_t length)
Construct an MutableArrayRef from a pointer and length.
constexpr ArrayRef(const std::array< T, N > &Arr)
Construct an ArrayRef from a std::array.
MutableArrayRef< T > drop_while(PredicateT Pred) const
Return a copy of *this with the first N elements satisfying the given predicate removed.
MutableArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
MutableArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
ArrayRef< T > drop_until(PredicateT Pred) const
Return a copy of *this with the first N elements not satisfying the given predicate removed...
std::vector< T > vec() const
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
MutableArrayRef(T &OneElt)
Construct an MutableArrayRef from a single element.
An opaque object representing a hash code.
ArrayRef(const T *data, size_t length)
Construct an ArrayRef from a pointer and length.
ArrayRef< 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...
ArrayRef(const ArrayRef< U *> &A, typename std::enable_if< std::is_convertible< U *const *, T const *>::value >::type *=nullptr)
Construct an ArrayRef<const T*> from ArrayRef<T*>.
ArrayRef(const SmallVectorTemplateCommon< U *, DummyT > &Vec, typename std::enable_if< std::is_convertible< U *const *, T const *>::value >::type *=nullptr)
Construct an ArrayRef<const T*> from a SmallVector<T*>.
MutableArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
bool operator!=(uint64_t V1, const APInt &V2)
reverse_iterator rend() const
This is the part of SmallVectorTemplateBase which does not depend on whether the type T is a POD...
ArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
constexpr ArrayRef(const T(&Arr)[N])
Construct an ArrayRef from a C array.
MutableArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
OwningArrayRef(ArrayRef< T > Data)
bool equals(ArrayRef RHS) const
equals - Check for element-wise equality.
OwningArrayRef(size_t Size)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This is equivalent to an IR comdat.
constexpr MutableArrayRef(std::array< T, N > &Arr)
Construct an ArrayRef from a std::array.
ArrayRef(const T *begin, const T *end)
Construct an ArrayRef from a range.
MutableArrayRef< T > drop_until(PredicateT Pred) const
Return a copy of *this with the first N elements not satisfying the given predicate removed...
ArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
T & back() const
back - Get the last element.
bool operator==(uint64_t V1, const APInt &V2)
MutableArrayRef(NoneType)
Construct an empty MutableArrayRef from None.
OutputIt copy(R &&Range, OutputIt Out)
MutableArrayRef(SmallVectorImpl< T > &Vec)
Construct an MutableArrayRef from a SmallVector.
bool empty() const
empty - Check if the array is empty.