Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:13:36

0001 // -*- C++ -*-
0002 //
0003 // This file is part of YODA -- Yet more Objects for Data Analysis
0004 // Copyright (C) 2008-2024 The YODA collaboration (see AUTHORS for details)
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             //We will see if the following will work:
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             //Cache ended as a public function since rewriting lowerBound() is pointless
0031             std::map<double, size_t> _cache;
0032         };
0033     }
0034 }
0035 
0036 #endif