Loading [MathJax]/extensions/tex2jax.js
chunkedseq
container library for large in-memory data sets
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
graphviz_output.cpp
Go to the documentation of this file.
1 
13 #include <string>
14 #include <set>
15 
16 #include "cmdline.hpp"
17 #include "chunkedseq.hpp"
18 
19 int main(int argc, char** argv) {
20  pasl::util::cmdline::set(argc, argv);
21 
23  using vertex_set_type = std::set<const void*>;
24 
25  string_type c;
26 
27  std::string str = "Functions delay binding; data structures induce binding. Moral: Structure data late in the programming process.";
28 
29  for (int i = 0; i < str.size(); i++)
30  c.push_back(str[i]);
31 
32  for (int i = 0; i < 500; i++) {
33  string_type d;
34  size_t k = rand() % c.size();
35  c.split(k, d);
36  c.concat(d);
37  }
38 
39  /*
40  for (int i = 0; i < c.size(); i++)
41  std::cout << c[i];
42  std::cout << std::endl;
43  */
44 
45  vertex_set_type vtxset;
46 
47  auto add_edge = [&] (const void* src, const void* dst) {
48  vtxset.insert(src);
49  vtxset.insert(dst);
50  std::cout << (long)dst << " -- " << (long)src << std::endl;
51  };
52 
53  auto process_chunk = [&] <typename Chunk> (Chunk* c) {
54  std::string str;
55  c->for_each([&] (char c) {
56  str += c;
57  });
58  auto it = vtxset.find(c);
59  vtxset.erase(it);
60  std::cout << (long)c << "[shape=record,label=\"" << str << "\"]" << std::endl;
61  };
62 
63  std::cout << "graph g{" << std::endl;
64  std::cout << "rankdir=LR" << std::endl;
65  std::cout << "ratio=auto" << std::endl;
66  c.reveal_internal_structure(add_edge, process_chunk);
67  for (auto it = vtxset.begin(); it != vtxset.end(); it++)
68  std::cout << (long)*it << "[shape=record,label=\"\"]" << std::endl;
69  std::cout << "}" << std::endl;
70 
71  return 0;
72 }
void push_back(const value_type &x)
Adds item at the end.
int main(int argc, char **argv)
Chunked-sequence functor.