75 template<
class VALTYPE>
85 inline VALTYPE&
GetCache(
unsigned int id)
const;
88 typedef std::vector<VALTYPE*> cache_container;
102 template<
class VALTYPE>
109 inline VALTYPE*&
GetCache(
unsigned int id)
const;
112 typedef std::vector<VALTYPE*> cache_container;
128 typedef std::vector<G4double> cache_container;
144 cout<<
"Generic template"<<endl;
148 cache =
new cache_container;
149 if ( cache->size() <= id )
150 cache->resize(
id+1,static_cast<V*>(0));
151 if ( (*cache)[
id] == 0 ) (*cache)[id]=
new V;
160 cout<<
"Destroying element"<<
id<<
" is last?"<<last<<endl;
162 if ( cache->size() <
id && (*cache)[id] ) {
176 return *(cache->operator[](id));
188 cout<<
"Pointer template"<<endl;
191 cache =
new cache_container;
192 if ( cache->size() <= id )
193 cache->resize(
id+1,static_cast<V*>(0));
203 cout<<
"Destroying element"<<
id<<
" is last?"<<last<<
"-Pointer template specialization-"<<endl;
205 if ( cache->size() <
id && (*cache)[id] ) {
220 return (cache->operator[](
id));
230 cout<<
"Specialized template for G4double"<<endl;
233 cache =
new cache_container;
234 if ( cache->size() <= id )
235 cache->resize(
id+1,static_cast<G4double>(0));
239 if ( cache && last ) {
241 cout<<
"Destroying element"<<
id<<
" is last?"<<last<<
"-Pointer template specialization-"<<endl;
249 return cache->operator[](id);
void Initialize(unsigned int id)
VALTYPE & GetCache(unsigned int id) const
void Destroy(unsigned int id, G4bool last)