55{
57
58 double precision;
60
61 try {
62
63 JParser<> zap(
"Example program to test hash collection.");
64
67
68 zap(argc, argv);
69 }
70 catch(const exception &error) {
71 FATAL(error.what() << endl);
72 }
73
74
76
78
79 hash_collection buffer(precision);
80
81
82 set<double> input = { 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0 };
84
86 buffer.insert(*x);
87 buffer.insert(*x);
88 }
89
90 for (hash_collection::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
92 }
93
94 ASSERT(buffer.size() == input.size(),
"Test of buffer size with multiple inserts of same element.");
95
96
98
99 DEBUG(
FIXED(5,2) << *x <<
' ' << buffer.getIndex(*x) << endl);
100
101 ASSERT(buffer.has(*x),
"Test of buffer content.");
102 }
103
104 {
105 hash_collection out(precision);
106
107 out = buffer;
108
110
111 DEBUG(
FIXED(5,2) << *x <<
' ' << out.getIndex(*x) << endl);
112
113 ASSERT(out.has(*x),
"Test of buffer content after assignment.");
114 }
115 }
116
118
119 hash_collection::iterator p = buffer.find(*x);
120
121 DEBUG(
"find " <<
FIXED(5,2) << *x <<
" at position " <<
distance(buffer.begin(),p) <<
' ' << buffer.getIndex(*x) << endl);
122
123 buffer.erase(p);
124 }
125
127
128 ASSERT(buffer.has(*x) == (rm.count(*x) == 0),
"Test of buffer content after erase.");
129 }
130
131 return 0;
132}
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.