10 #ifndef LLVM_ADT_ARRAYREF_H
11 #define LLVM_ADT_ARRAYREF_H
58 : Data(&OneElt), Length(1) {}
62 : Data(data), Length(length) {}
66 : Data(begin), Length(end - begin) {}
73 : Data(Vec.
data()), Length(Vec.
size()) {
79 : Data(Vec.
empty() ? (
T*)0 : &Vec[0]), Length(Vec.
size()) {}
84 : Data(Arr), Length(N) {}
86 #if LLVM_HAS_INITIALIZER_LISTS
88 ArrayRef(
const std::initializer_list<T> &Vec)
104 bool empty()
const {
return Length == 0; }
106 const T *
data()
const {
return Data; }
109 size_t size()
const {
return Length; }
120 return Data[Length-1];
125 if (Length != RHS.Length)
128 if (Data[i] != RHS.Data[i])
135 assert(N <=
size() &&
"Invalid specifier");
142 assert(N+M <=
size() &&
"Invalid specifier");
150 assert(Index < Length &&
"Invalid index!");
157 std::vector<T>
vec()
const {
158 return std::vector<T>(Data, Data+Length);
164 operator std::vector<T>()
const {
165 return std::vector<T>(Data, Data+Length);
224 assert(!this->
empty());
230 assert(!this->
empty());
236 assert(N <= this->
size() &&
"Invalid specifier");
243 assert(N+M <= this->
size() &&
"Invalid specifier");
251 assert(Index < this->
size() &&
"Invalid index!");
252 return data()[Index];
278 template <
typename T>
284 template <
typename T,
unsigned N>
296 template<
typename T,
size_t N>
312 return !(LHS == RHS);
const_iterator end(StringRef path)
Get end iterator over path.
const T & operator[](size_t Index) const
NoneType
A simple null object to allow implicit construction of Optional<T> and similar types without having to ...
const T & front() const
front - Get the first element.
const_iterator begin(StringRef path)
Get begin iterator over path.
ArrayRef(NoneType)
Construct an empty ArrayRef from None.
MutableArrayRef(T(&Arr)[N])
Construct an MutableArrayRef from a C array.
MutableArrayRef(std::vector< T > &Vec)
Construct a MutableArrayRef from a std::vector.
ArrayRef< T > slice(unsigned N, unsigned M) const
LLVM_CONSTEXPR ArrayRef(const T(&Arr)[N])
Construct an ArrayRef from a C array.
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.
reverse_iterator rbegin() const
ArrayRef< T > slice(unsigned N) const
slice(n) - Chop off the first N elements of the array.
MutableArrayRef< T > slice(unsigned N, unsigned M) const
size_t size() const
size - Get the array size.
reverse_iterator rend() const
ArrayRef(const SmallVectorTemplateCommon< T, U > &Vec)
MutableArrayRef(T *begin, T *end)
Construct an MutableArrayRef from a range.
ArrayRef()
Construct an empty ArrayRef.
bool equals(ArrayRef RHS) const
equals - Check for element-wise equality.
bool empty() const
empty - Check if the array is empty.
MutableArrayRef()
Construct an empty MutableArrayRef.
const T & back() const
back - Get the last element.
ArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
std::reverse_iterator< iterator > reverse_iterator
MutableArrayRef(T *data, size_t length)
Construct an MutableArrayRef from a pointer and length.
MutableArrayRef(T &OneElt)
Construct an MutableArrayRef from a single element.
ArrayRef(const T *data, size_t length)
Construct an ArrayRef from a pointer and length.
MutableArrayRef< T > slice(unsigned N) const
slice(n) - Chop off the first N elements of the array.
bool operator!=(uint64_t V1, const APInt &V2)
T & front() const
front - Get the first element.
ArrayRef(const T *begin, const T *end)
Construct an ArrayRef from a range.
T & operator[](size_t Index) const
bool operator==(uint64_t V1, const APInt &V2)
MutableArrayRef(NoneType)
Construct an empty MutableArrayRef from None.
MutableArrayRef(SmallVectorImpl< T > &Vec)
Construct an MutableArrayRef from a SmallVector.
T & back() const
back - Get the last element.
std::vector< T > vec() const