Jpp  15.0.1-rc.2-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JHashSet.cc File Reference

Example program to test JTOOLS::JHashSet class. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JTools/JHashSet.hh"
#include "JLang/JObjectID.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JTOOLS::JHashSet class.

Author
mdejong

Definition in file JHashSet.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 59 of file JHashSet.cc.

60 {
61  using namespace std;
62 
63  int debug;
64 
65  try {
66 
67  JParser<> zap("Example program to test hash set.");
68 
69  zap['d'] = make_field(debug) = 3;
70 
71  zap(argc, argv);
72  }
73  catch(const exception &error) {
74  FATAL(error.what() << endl);
75  }
76 
77 
78  using namespace JPP;
79 
80  typedef JHashSet<__A__> hash_set;
81 
82  hash_set buffer;
83 
84  for (int i = 1<<10; i != 0; i >>= 1) {
85  buffer.insert(__A__(i));
86  }
87 
88  buffer.erase(buffer.find(1<<2), buffer.find(1<<4));
89 
90  if (!buffer.erase(1<<4)) {
91  FATAL("Erasing value failed." << endl);
92  }
93 
94  for (hash_set::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
95 
96  cout << setw(4) << *i;
97  cout << " == ";
98 
99  hash_set::const_iterator p = buffer.find(*i);
100 
101  if (p != buffer.end())
102  cout << setw(4) << *p << endl;
103  else
104  FATAL("Inconsistent has set at " << *i << endl);
105  }
106 
107  return 0;
108 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General purpose class for hash set of elements.
Definition: JHashSet.hh:30
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
virtual bool insert(const value_type &element) override
Insert element.
Definition: JHashSet.hh:99