File indexing completed on 2026-05-05 08:54:56
0001
0002
0003
0004
0005
0006 #ifndef YODA_CACHEDVECTOR_H
0007 #define YODA_CACHEDVECTOR_H
0008
0009 #include <vector>
0010 #include <algorithm>
0011 #include <stdexcept>
0012 #include <iostream>
0013 #include <map>
0014
0015 namespace YODA {
0016 namespace Utils {
0017
0018
0019 template <typename T>
0020 class cachedvector : public std::vector<T> {
0021 public:
0022 cachedvector(){}
0023 cachedvector(const std::vector<T>& vec) : std::vector<T>(vec) {}
0024
0025
0026 void regenCache(){
0027 _cache.clear();
0028 for(size_t i=0; i < this->size(); i++)
0029 _cache.insert(std::make_pair(this->at(i).first, i));
0030 }
0031
0032
0033 std::map<double, size_t> _cache;
0034 };
0035
0036
0037 }
0038 }
0039
0040 #endif