File indexing completed on 2025-09-15 09:11:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_REveChunkManager
0013 #define ROOT_REveChunkManager
0014
0015 #include <ROOT/REveUtil.hxx>
0016
0017 #include "TArrayC.h"
0018
0019 #include <vector>
0020 #include <set>
0021
0022 namespace ROOT {
0023 namespace Experimental {
0024
0025
0026
0027
0028
0029 class REveChunkManager
0030 {
0031 private:
0032 REveChunkManager(const REveChunkManager&) = delete;
0033 REveChunkManager& operator=(const REveChunkManager&) = delete;
0034
0035 protected:
0036 Int_t fS;
0037 Int_t fN;
0038
0039 Int_t fSize;
0040 Int_t fVecSize;
0041 Int_t fCapacity;
0042
0043 std::vector<TArrayC*> fChunks;
0044
0045 void ReleaseChunks();
0046
0047 public:
0048 REveChunkManager();
0049 REveChunkManager(Int_t atom_size, Int_t chunk_size);
0050 virtual ~REveChunkManager();
0051
0052 void Reset(Int_t atom_size, Int_t chunk_size);
0053 void Refit();
0054
0055 Int_t S() const { return fS; }
0056 Int_t N() const { return fN; }
0057
0058 Int_t Size() const { return fSize; }
0059 Int_t VecSize() const { return fVecSize; }
0060 Int_t Capacity() const { return fCapacity; }
0061
0062 Char_t* Atom(Int_t idx) const { return fChunks[idx/fN]->fArray + idx%fN*fS; }
0063 Char_t* Chunk(Int_t chk) const { return fChunks[chk]->fArray; }
0064 Int_t NAtoms(Int_t chk) const { return (chk < fVecSize-1) ? fN : (fSize-1)%fN + 1; }
0065
0066 Char_t* NewAtom();
0067 Char_t* NewChunk();
0068
0069
0070
0071
0072 struct iterator
0073 {
0074 REveChunkManager &fPlex;
0075 Char_t *fCurrent{nullptr};
0076 Int_t fAtomIndex{-1};
0077 Int_t fNextChunk{0};
0078 Int_t fAtomsToGo{0};
0079
0080 const std::set<Int_t> *fSelection{nullptr};
0081 std::set<Int_t>::const_iterator fSelectionIterator;
0082
0083 iterator(REveChunkManager &p) : fPlex(p) {}
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098 Bool_t next();
0099 void reset() { fCurrent = nullptr; fAtomIndex = -1; fNextChunk = fAtomsToGo = 0; }
0100
0101 Char_t* operator()() { return fCurrent; }
0102 Char_t* operator*() { return fCurrent; }
0103 Int_t index() { return fAtomIndex; }
0104 };
0105
0106 };
0107
0108
0109
0110 inline Char_t* REveChunkManager::NewAtom()
0111 {
0112 Char_t *a = (fSize >= fCapacity) ? NewChunk() : Atom(fSize);
0113 ++fSize;
0114 return a;
0115 }
0116
0117
0118
0119
0120
0121
0122 template<class T>
0123 class REveChunkVector : public REveChunkManager
0124 {
0125 private:
0126 REveChunkVector(const REveChunkVector&) = delete;
0127 REveChunkVector& operator=(const REveChunkVector&) = delete;
0128
0129 public:
0130 REveChunkVector() = default;
0131 REveChunkVector(Int_t chunk_size) : REveChunkManager(sizeof(T), chunk_size) {}
0132 ~REveChunkVector() override {}
0133
0134 void Reset(Int_t chunk_size) { Reset(sizeof(T), chunk_size); }
0135
0136 T *At(Int_t idx) { return reinterpret_cast<T*>(Atom(idx)); }
0137 T &Ref(Int_t idx) { return *At(idx); }
0138 };
0139
0140 }
0141 }
0142
0143 #endif