File indexing completed on 2025-04-19 09:13:36
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 template <typename T>
0018 class cachedvector : public std::vector<T> {
0019 public:
0020 cachedvector(){}
0021 cachedvector(const std::vector<T>& vec) : std::vector<T>(vec) {}
0022
0023
0024 void regenCache(){
0025 _cache.clear();
0026 for(size_t i=0; i < this->size(); i++)
0027 _cache.insert(std::make_pair(this->at(i).first, i));
0028 }
0029
0030
0031 std::map<double, size_t> _cache;
0032 };
0033 }
0034 }
0035
0036 #endif