27 this->precision = precision;
37 inline int operator()(
const double key)
const
39 return (
int) ((key + 0.5*precision) / precision);
54 int main(
int argc,
char **argv)
63 JParser<> zap(
"Example program to test hash collection.");
70 catch(
const exception &error) {
71 FATAL(error.what() << endl);
77 typedef JHashCollection<double, get_value> hash_collection;
79 hash_collection buffer(precision);
82 set<double> input = { 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0 };
90 for (hash_collection::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
94 ASSERT(buffer.size() == input.size(),
"Test of buffer size with multiple inserts of same element.");
99 DEBUG(
FIXED(5,2) << *x <<
' ' << buffer.getIndex(*x) << endl);
101 ASSERT(buffer.has(*x),
"Test of buffer content.");
105 hash_collection out(precision);
111 DEBUG(
FIXED(5,2) << *x <<
' ' << out.getIndex(*x) << endl);
113 ASSERT(out.has(*x),
"Test of buffer content after assignment.");
119 hash_collection::iterator p = buffer.find(*x);
121 DEBUG(
"find " <<
FIXED(5,2) << *x <<
" at position " <<
distance(buffer.begin(),p) <<
' ' << buffer.getIndex(*x) << endl);
128 ASSERT(buffer.has(*x) == (rm.count(*x) == 0),
"Test of buffer content after erase.");
Utility class to parse command line options.
int main(int argc, char *argv[])
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
General purpose class for a hash collection of unique elements.
Auxiliary data structure for floating point format specification.
#define ASSERT(A,...)
Assert macro.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
Utility class to parse command line options.
#define DEBUG(A)
Message macros.