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
test_chunkedseq.cpp
Go to the documentation of this file.
1 
13 // #define DEBUG_MIDDLE_SEQUENCE 1
14 
15 
16 #include "cmdline.hpp"
17 #include "chunkedseq.hpp"
18 #include "test_seq.hpp"
19 
20 using namespace pasl::data;
21 
22 
23 /***********************************************************************/
24 // Specification of integer items
25 
26 class IntItem {
27  int value;
28 
29 public:
30  IntItem() : value(0) {}
31 
32  static IntItem from_int(int n) {
33  IntItem x;
34  x.value = n;
35  return x;
36  }
37 
38  static int to_int(IntItem& x) {
39  return x.value;
40  }
41 
42  static void print(IntItem& x) {
43  printf("%d", IntItem::to_int(x));
44  }
45 
46  static void free(IntItem& x) {
47  }
48 
49 };
50 
51 /***********************************************************************/
52 // Specialization of the sequence to integer items
53 
54 template<int Chunk_capacity>
56 
57 
58 /***********************************************************************/
59 
60 int main(int argc, char** argv) {
61  pasl::util::cmdline::set(argc, argv);
62 
63  size_t chunk_capacity = (size_t) pasl::util::cmdline::parse_or_default_int("chunk_capacity", 2);
64  if (chunk_capacity == 2)
65  TestSeq<IntSeqOf<2>,IntItem>::execute_test();
66  else if (chunk_capacity == 4)
67  TestSeq<IntSeqOf<4>,IntItem>::execute_test();
68  else
69  pasl::util::cmdline::die("unsupported capacity");
70 
71  return 0;
72 }
73 
74 
75 /***********************************************************************/
Unit tests for sequences.
int main(int argc, char **argv)
const int chunk_capacity
[weighted_split_example]
Chunked-sequence functor.