5#ifndef QV4SPARSEARRAY_H
6#define QV4SPARSEARRAY_H
21#include <QtCore/qlist.h>
25#include <QtCore/qdebug.h>
53 void setColor(
Color c) {
if (c == Black) p |= Black;
else p &= ~Black; }
131 void recalcMostLeftNode();
177inline SparseArrayNode *SparseArray::findNode(uint akey)
const
179 SparseArrayNode *n = root();
182 if (akey == n->size_left) {
184 }
else if (akey < n->size_left) {
187 akey -= n->size_left;
195inline uint SparseArray::pop_front()
197 uint idx = UINT_MAX ;
199 SparseArrayNode *n = findNode(0);
204 SparseArrayNode *rootNode = root();
206 rootNode->size_left -= 1;
207 rootNode = rootNode->left;
213inline void SparseArray::push_front(uint value)
216 SparseArrayNode *n = root();
225inline uint SparseArray::pop_back(uint len)
231 SparseArrayNode *n = findNode(len - 1);
239inline void SparseArray::push_back(uint index, uint len)
241 SparseArrayNode *n = insert(len);
246inline void SparseArray::dump()
const
248 const SparseArrayNode *it = begin();
249 qDebug() <<
"map dump:";
250 while (it != end()) {
251 const SparseArrayNode *n = it;
253 while (n && n != root()) {
257 QByteArray space(4*depth,
' ');
258 qDebug() << space << (it->color() == SparseArrayNode::Red ?
"Red " :
"Black") << it << it->size_left << it->left << it->right
259 << it->key() << it->value;
262 qDebug() <<
"---------";
267inline SparseArrayNode *SparseArray::erase(SparseArrayNode *n)
272 SparseArrayNode *next = n->nextNode();
277inline QList<
int> SparseArray::keys()
const
280 res.reserve(numEntries);
281 SparseArrayNode *n = mostLeftNode;
283 res.append(n->key());
289inline const SparseArrayNode *SparseArray::lowerBound(uint akey)
const
291 if (SparseArrayNode *n = root()) {
292 if (
const SparseArrayNode *lb = n->lowerBound(akey))
300inline SparseArrayNode *SparseArray::lowerBound(uint akey)
302 if (SparseArrayNode *n = root()) {
303 if (SparseArrayNode *lb = n->lowerBound(akey))
311inline const SparseArrayNode *SparseArray::upperBound(uint akey)
const
313 if (SparseArrayNode *n = root()) {
314 if (
const SparseArrayNode *ub = n->upperBound(akey))
322inline SparseArrayNode *SparseArray::upperBound(uint akey)
324 if (SparseArrayNode *n = root()) {
325 if (SparseArrayNode *ub = n->upperBound(akey))
ArrayElementLessThan(ExecutionEngine *engine, const Value &comparefn)
bool operator()(Value v1, Value v2) const
ReturnedValue operator*() const
OptionalReturnedValue(ReturnedValue v)
ReturnedValue operator->() const
DECLARE_HEAP_OBJECT(StrictArgumentsObject, Object)
DECLARE_EXPORTED_HEAP_OBJECT(Object, Base)
DECLARE_HEAP_OBJECT(ArgumentsObject, Object)
DECLARE_HEAP_OBJECT(MemberData, Base)
DECLARE_HEAP_OBJECT(ArrayData, Base)
Q_STATIC_ASSERT(std::is_trivial_v< ArrayData >)
Scoped< FunctionObject > ScopedFunctionObject
void sortHelper(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
QVector< StackFrame > StackTrace
int qYouForgotTheQ_MANAGED_Macro(T, T)
Scoped< Object > ScopedObject
ReturnedValue value_convert(ExecutionEngine *e, const Value &v)
Scoped< ArrayObject > ScopedArrayObject
Scoped< String > ScopedString
Scoped< StringOrSymbol > ScopedStringOrSymbol
void qYouForgotTheQ_MANAGED_Macro(T1, T2)
@ Attr_ReadOnly_ButConfigurable
Q_STATIC_ASSERT(sizeof(CppStackFrame)==sizeof(JSTypesStackFrame))
Scoped< ExecutionContext > ScopedContext
Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_RELOCATABLE_TYPE)
DEFINE_OBJECT_VTABLE(StrictArgumentsObject)
DEFINE_OBJECT_VTABLE(ArgumentsObject)
#define V4_ARRAYDATA(DataClass)
#define V4_MANAGED(DataClass, superClass)
#define V4_MANAGED_SIZE_TEST
#define V4_MANAGED_ITSELF(DataClass, superClass)
#define Q_MANAGED_TYPE(type)
#define V4_INTERNALCLASS(c)
static qint64 virtualGetLength(const Managed *m)
static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *desc, PropertyAttributes attrs)
Heap::CallContext * context() const
static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
static OwnPropertyKeyIterator * virtualOwnPropertyKeys(const Object *m, Value *target)
static bool isNonStrictArgumentsObject(Managed *m)
static bool virtualDeleteProperty(Managed *m, PropertyKey id)
bool fullyCreated() const
void removeMapping(uint arg)
static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
bool isMapped(uint arg) const
static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs)
static qint64 virtualGetLength(const Managed *m)
QStringList toQStringList() const
void(* setAttribute)(Object *o, uint index, PropertyAttributes attrs)
bool(* putArray)(Object *o, uint index, const Value *values, uint n)
bool(* put)(Object *o, uint index, const Value &value)
void(* push_front)(Object *o, const Value *values, uint n)
ReturnedValue(* get)(const Heap::ArrayData *d, uint index)
bool(* del)(Object *o, uint index)
ReturnedValue(* pop_front)(Object *o)
static constexpr size_t offset
void set(EngineBase *e, HeapBasePtr b)
void set(EngineBase *e, const Value &newVal)
void init(const QStringList &list)
PropertyAttributes attributes(uint i) const
uint mappedIndex(uint index) const
void setData(EngineBase *e, uint index, Value newVal)
const Value & data(uint index) const
uint mappedIndex(uint index) const
PropertyAttributes attributes(uint i) const
static Heap::MemberData * allocate(QV4::ExecutionEngine *e, uint n, Heap::MemberData *old=nullptr)
const Value * data() const
void set(EngineBase *e, uint index, Value v)
const Value & operator[](uint idx) const
void set(EngineBase *e, uint index, Heap::Base *b)
PropertyKey next(const Object *o, Property *pd=nullptr, PropertyAttributes *attrs=nullptr) override
const Value * operator->() const
const Value & operator*() const
void set(EngineBase *e, Value newVal)
void setGetter(FunctionObject *g)
Heap::FunctionObject * getter() const
bool isSubset(const PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const
void setSetter(FunctionObject *s)
void fullyPopulated(PropertyAttributes *attrs)
bool isCompatible(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const
void copy(const Property *other, PropertyAttributes attrs)
void completed(PropertyAttributes *attrs)
Property(Heap::FunctionObject *getter, Heap::FunctionObject *setter)
Heap::FunctionObject * setter() const
void merge(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs)
SparseArrayNode * copy(SparseArray *d) const
SparseArrayNode * lowerBound(uint key)
const SparseArrayNode * previousNode() const
SparseArrayNode * parent() const
SparseArrayNode * nextNode()
SparseArrayNode * upperBound(uint key)
const SparseArrayNode * nextNode() const
SparseArrayNode * previousNode()
void setParent(SparseArrayNode *pp)
SparseArrayNode * upperBound(uint key)
SparseArrayNode * erase(SparseArrayNode *n)
void push_back(uint at, uint len)
SparseArrayNode * lowerBound(uint key)
const SparseArrayNode * begin() const
SparseArrayNode * insert(uint akey)
QList< int > keys() const
SparseArrayNode * findNode(uint akey) const
void freeTree(SparseArrayNode *root, int alignment)
const SparseArrayNode * end() const
const Value * data() const
void set(EngineBase *e, uint index, Value v)
void set(EngineBase *e, uint index, Value::HeapBasePtr b)
void mark(MarkStack *markStack)
Value::HeapBasePtr base()
const Value & operator[](uint index) const
static constexpr size_t offset