File: store_to_file.cpp

package info (click to toggle)
libsdsl 2.1.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 3,980 kB
  • sloc: cpp: 42,286; makefile: 1,171; ansic: 318; sh: 201; python: 27
file content (44 lines) | stat: -rw-r--r-- 935 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <sdsl/vectors.hpp>
#include <fstream>
#include <iostream>

using namespace sdsl;
using namespace std;

int main()
{
    cout << (has_serialize<bit_vector>::value)  << endl;
    cout << (has_serialize<uint64_t>::value)  << endl;

    {
        ofstream out("data.sdsl");
        bit_vector b = {1,0,0,0,1,1,0};
        serialize(b, out);
    }
    {
        ifstream in("data.sdsl");
        bit_vector b;
        load(b, in);
        cout << b << endl;
    }
    {
        uint64_t x = 42;
        store_to_file(x, "data.sdsl");
    }
    {
        uint64_t x = 0;
        load_from_file(x, "data.sdsl");
        cout << x << endl;
    }
    {
        std::vector<uint32_t> x(10, 5);
        store_to_file(x, "data.sdsl");
    }
    {
        std::vector<uint32_t> x;
        load_from_file(x, "data.sdsl");
        cout << x.size() << endl;
        for (size_t i=0; i<x.size(); ++i)
            cout << x[i] << endl;
    }
}