Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VariableArray.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VariableArray.cc
1 #include "VariableArray.h"
2 
3 #include <ostream>
4 
5 using namespace std;
6 
7 VariableArray::VariableArray(const unsigned int idval)
8  : id(idval)
9  , nVal(0)
10  , sval(nullptr)
11 {
12  return;
13 }
14 
16 {
17  Reset();
18  return;
19 }
20 
21 void VariableArray::identify(ostream &os) const
22 {
23  os << "contain " << nVal << " values" << endl;
24  for (unsigned int i = 0; i < nVal; i++)
25  {
26  os << "n: " << i << " val: " << sval[i] << endl;
27  }
28  return;
29 }
30 
31 void VariableArray::set_val(const vector<short> &vec)
32 {
33  nVal = vec.size();
34  sval = new short[nVal];
35  vector<short>::const_iterator iter;
36  unsigned int i = 0;
37  for (iter = vec.begin(); iter != vec.end(); ++iter)
38  {
39  sval[i++] = *iter;
40  }
41  return;
42 }
43 
45 {
46  delete[] sval;
47  sval = nullptr;
48  nVal = 0;
49  return;
50 }