//#####################################################################
// Copyright 2023, Craig Schroeder.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYREGHT.txt.
//#####################################################################
#ifndef __REGISTER__
#define __REGISTER__

#include <Core/Arrays/ARRAY.h>
#include <Core/Symbolics/REG.h>
#include <Core/Vectors/VECTOR.h>

namespace PhysBAM{

template<class T>
class REG_ARRAY
{
public:
    VECTOR<ARRAY<T>,6> a;
    T& operator()(REG r){auto [t,v]=r.Parts();return a(t)(v);}
    const T& operator()(REG r) const {auto [t,v]=r.Parts();return a(t)(v);}
    T& Get_Resize(REG r)
    {
        auto [t,v]=r.Parts();
        auto& b=a(t);
        if(v>=b.m) b.Resize(v+1);
        return b(v);
    }
    void Resize(REG r,T x={})
    {
        auto [t,v]=r.Parts();
        a(t).Resize(v,init_new,x);
    }
};

}
#endif
