File: replace_int_vector_value.cpp

package info (click to toggle)
seqan3 3.0.2%2Bds-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 16,052 kB
  • sloc: cpp: 144,641; makefile: 1,288; ansic: 294; sh: 228; xml: 217; javascript: 50; python: 27; php: 25
file content (31 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (19)
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
#include "sdsl/int_vector.hpp"
#include <string>
#include <cstdlib>

using namespace std;
using namespace sdsl;

int main(int argc, char* argv[])
{
    if (argc < 4) {
        cout << "Usage: " << argv[0] << " FILE X Y" << endl;
        cout << "  Loads an int_vector<>(SIZE, DEFAULT_VALUE, WIDTH)" << endl;
        cout << "  and replaces all values X with Y and stores the " << endl;
        cout << "  result in the same file." << endl;
        return 1;
    }
    uint64_t x = atoi(argv[2]);
    uint64_t y = atoi(argv[3]);
    int_vector_buffer<> v(argv[1]);
    if (v.good()) {
        for (size_t i=0; i<v.size(); ++i) {
            uint64_t val = v[i];
            if (val == x) {
                v[i] = y;
            }
        }
    } else {
        cerr << "Could not open int_vector<> file " << argv[1] << endl;
        return 1;
    }
}