A Value that's an array. */
| 22 | |
| 23 | /** A Value that's an array. */ |
| 24 | class Array : public Value { |
| 25 | struct impl { |
| 26 | const Value* _first; |
| 27 | uint32_t _count; |
| 28 | uint8_t _width; |
| 29 | |
| 30 | impl(const Value*) noexcept; |
| 31 | const Value* second() const noexcept FLPURE {return offsetby(_first, _width);} |
| 32 | const Value* firstValue() const noexcept FLPURE; |
| 33 | const Value* deref(const Value*) const noexcept FLPURE; |
| 34 | const Value* operator[] (unsigned index) const noexcept FLPURE; |
| 35 | size_t indexOf(const Value *v) const noexcept FLPURE; |
| 36 | void offset(uint32_t n); |
| 37 | bool isMutableArray() const noexcept FLPURE {return _width > 4;} |
| 38 | }; |
| 39 | |
| 40 | public: |
| 41 | |
| 42 | /** The number of items in the array. */ |
| 43 | uint32_t count() const noexcept FLPURE; |
| 44 | |
| 45 | bool empty() const noexcept FLPURE; |
| 46 | |
| 47 | /** Accesses an array item. Returns nullptr for out of range index. |
| 48 | If you're accessing a lot of items of the same array, it's faster to make an |
| 49 | iterator and use its sequential or random-access accessors. */ |
| 50 | const Value* get(uint32_t index) const noexcept FLPURE; |
| 51 | |
| 52 | /** If this array is mutable, returns the equivalent MutableArray*, else returns nullptr. */ |
| 53 | MutableArray* asMutable() const FLPURE; |
| 54 | |
| 55 | /** An empty Array. */ |
| 56 | static const Array* const kEmpty; |
| 57 | |
| 58 | using iterator = ArrayIterator; |
| 59 | |
| 60 | inline iterator begin() const noexcept; |
| 61 | |
| 62 | constexpr Array() :Value(internal::kArrayTag, 0, 0) { } |
| 63 | |
| 64 | protected: |
| 65 | internal::HeapArray* heapArray() const; |
| 66 | |
| 67 | private: |
| 68 | friend class Value; |
| 69 | friend class ArrayIterator; |
| 70 | friend class Dict; |
| 71 | friend class DictIterator; |
| 72 | template <bool WIDE> friend struct dictImpl; |
| 73 | friend class internal::HeapArray; |
| 74 | }; |
| 75 | |
| 76 | |
| 77 | /** A stack-based array iterator */ |
nothing calls this directly
no outgoing calls
no test coverage detected