#pragma once
#include "../../stddef.hpp"

namespace JabyEngine {
    template<typename T>
    struct ArrayRange {
        T*     start = nullptr;
        size_t size  = 0;

        constexpr ArrayRange() = default;
        constexpr ArrayRange(T* start, size_t size) : start(start), size(size) {
        }

        constexpr void skip(size_t elements) {
            this->start += elements;
            this->size  -= elements;
        }

        T& pop() {
            T& value = *this->start;
            ArrayRange::skip(1);
            return value;
        }

        constexpr operator bool() const {
            return this->size > 0;
        }

        constexpr bool operator>=(size_t elements) const {
            return this->size >= elements;
        }

        constexpr T& operator[](size_t idx) {
            return this->start[idx];
        }

        constexpr const T& operator[](size_t idx) const {
            return this->start[idx];
        }
    };
}