yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.2
cachedvector.h
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// This file is part of YODA -- Yet more Objects for Data Analysis
4// Copyright (C) 2008-2024 The YODA collaboration (see AUTHORS for details)
5//
6#ifndef YODA_CACHEDVECTOR_H
7#define YODA_CACHEDVECTOR_H
8
9#include <vector>
10#include <algorithm>
11#include <stdexcept>
12#include <iostream>
13#include <map>
14
15namespace YODA {
16 namespace Utils {
17 template <typename T>
18 class cachedvector : public std::vector<T> {
19 public:
20 cachedvector(){}
21 cachedvector(const std::vector<T>& vec) : std::vector<T>(vec) {}
22
23 //We will see if the following will work:
24 void regenCache(){
25 _cache.clear();
26 for(size_t i=0; i < this->size(); i++)
27 _cache.insert(std::make_pair(this->at(i).first, i));
28 }
29
30 //Cache ended as a public function since rewriting lowerBound() is pointless
31 std::map<double, size_t> _cache;
32 };
33 }
34}
35
36#endif
Anonymous namespace to limit visibility.