BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
hash_vector.hh
Go to the documentation of this file.
1//======================================================================
2// File: hash.h
3// Author: Timothy A. Budd
4// Description: This file contains the interface and implementation
5// of the hash template classes.
6//
7// Copyright (c) 1992 by Timothy A. Budd. All Rights Reserved.
8// may be reproduced for any non-commercial purpose
9//
10// Modified: March 11, 1998 by Kyle Pope
11// Inherit from STL std::vector<T> class.
12//
13//======================================================================
14
15#ifndef HASH_H
16#define HASH_H
17
18#include <stddef.h>
19#include <vector>
20
21//----------------------------------------------------------------------
22// class hashVector
23// vector indexed using hashed key values
24// template types are type of key
25// and type of value stored in vector
26//----------------------------------------------------------------------
27
28//template <class T> class vector;
29
30using namespace std;
31
32template <class H, class T> class hashVector : public vector<T>
33{
34public:
35 // constructors
36 hashVector(size_t max, size_t (*f)(const H &));
37 hashVector(size_t max, size_t (*f)(const H &), T & initialValue);
39
40 // subscript operation
41 T & operator [] (const H & index);
42 const T & operator [] (const H & index) const;
43
44private:
45 // store the hash function
46 size_t (*hashfun)(const H &);
47};
48
49//----------------------------------------------------------------------
50// class hashVector implementation
51//----------------------------------------------------------------------
52
53template <class H, class T>
54inline hashVector<H, T>::hashVector(size_t max, size_t (*f)(const H &))
55 : vector<T>(max), hashfun(f)
56{
57 // no further initialization
58}
59
60
61
62template <class H, class T>
63inline hashVector<H, T>::hashVector(size_t max, size_t (*f)(const H&), T& initialValue)
64 : vector<T>(max, initialValue), hashfun(f)
65{
66 // no further initialization
67}
68
69
70
71template <class H, class T>
73 : vector<T>(v), hashfun(v.hashfun)
74{
75 // no further initialization
76}
77
78
79
80template <class H, class T>
81inline T & hashVector<H, T>::operator[] (const H & index)
82{
83 // subscript a hash vector
84 // hash the index value before indexing vector
85 return vector<T>::operator[] ((*hashfun)(index) % size());
86}
87
88
89template <class H, class T>
90inline const T & hashVector<H, T>::operator[] (const H & index) const
91{
92 // subscript a hash vector
93 // hash the index value before indexing vector
94 return vector<T>::operator[] ((*hashfun)(index) % size());
95}
96
97//----------------------------------------------------------------------
98// miscellaneous template functions
99//----------------------------------------------------------------------
100
101#endif
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
hashVector(size_t max, size_t(*f)(const H &))
Definition: hash_vector.hh:54
T & operator[](const H &index)
Definition: hash_vector.hh:81
IMPLICIT REAL *A H
Definition: myXsection.h:1