9 #ifndef MLIR_SUPPORT_ADTEXTRAS_H
10 #define MLIR_SUPPORT_ADTEXTRAS_H
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/SmallVector.h"
37 vector.insert(vector.begin() + index, value);
42 if (isNonOwning() && index == 0) {
43 nonOwning = nonOwning.drop_front();
44 }
else if (isNonOwning() && index ==
size() - 1) {
45 nonOwning = nonOwning.drop_back();
48 vector.erase(vector.begin() + index);
52 void set(
size_t index, T value) { ensureCopy()[index] = value; }
59 return nonOwning.empty() ?
ArrayRef<T>(owningStorage) : nonOwning;
63 bool isNonOwning()
const {
return !nonOwning.empty(); }
65 SmallVector<T> &ensureCopy() {
71 owningStorage = SmallVector<T>(nonOwning);
77 ArrayRef<T> nonOwning;
78 SmallVector<T> owningStorage;
CopyOnWriteArrayRef(ArrayRef< T > array)
void set(size_t index, T value)
CopyOnWriteArrayRef & operator=(ArrayRef< T > array)
void insert(size_t index, T value)
Include the generated interface declarations.