Belle II Software development
Helpers.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10
11namespace Belle2 {
22 template<class T>
23 void checkResizeClear(std::vector<T>& vectorToCheck, uint limit)
24 {
25
26 if (vectorToCheck.capacity() > limit) {
27 B2DEBUG(29, "Capacity of vector too large, create fresh vector and swap.");
28 std::vector<T> tmp;
29 std::swap(vectorToCheck, tmp);
30 tmp.clear();
31 }
32 vectorToCheck.clear();
33 vectorToCheck.reserve(limit / 4);
34 }
35
37}
void checkResizeClear(std::vector< T > &vectorToCheck, uint limit)
Check capacity of a vector and create a fresh one if capacity too large If the capacity of a std::vec...
Definition: Helpers.h:23
Abstract base class for different kinds of events.