Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
testBitArray.C
Go to the documentation of this file.
1
2/* Aleph-w
3
4 / \ | | ___ _ __ | |__ __ __
5 / _ \ | |/ _ \ '_ \| '_ \ ____\ \ /\ / / Data structures & Algorithms
6 / ___ \| | __/ |_) | | | |_____\ V V / version 1.9c
7 /_/ \_\_|\___| .__/|_| |_| \_/\_/ https://github.com/lrleon/Aleph-w
8 |_|
9
10 This file is part of Aleph-w library
11
12 Copyright (c) 2002-2018 Leandro Rabindranath Leon
13
14 Permission is hereby granted, free of charge, to any person obtaining a copy
15 of this software and associated documentation files (the "Software"), to deal
16 in the Software without restriction, including without limitation the rights
17 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 copies of the Software, and to permit persons to whom the Software is
19 furnished to do so, subject to the following conditions:
20
21 The above copyright notice and this permission notice shall be included in all
22 copies or substantial portions of the Software.
23
24 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 SOFTWARE.
31*/
32
33# include <fstream>
34# include <iostream>
35# include <bitArray.H>
36
37using namespace std;
38using namespace Aleph;
39
40void print(BitArray & array)
41{
42 cout << "size = " << array.size() << endl;
43
44 for (size_t i = 0; i < array.size(); ++i)
45 cout << array[i] << " ";
46 cout << endl;
47}
48
49int main()
50{
51 BitArray array(40);
52
53 for (int i = 0; i < 20; i++)
54 {
55 array[i] = 0;
56 }
57
58 array[20] = 1;
59 array[27] = 1;
60 array[22] = 1;
61
62 for (int i = 30; i < 40; i++)
63 {
64 array[i] = array[i];
65 }
66
67 print(array);
68
69 cout << endl;
70
71 {
72 ofstream out("test.bits");
73 array.save(out);
74 }
75
76 ifstream in("test.bits");
77 array.load(in);
78
79 print(array);
80}
Space-efficient bit array implementation.
size_t size_t int32_t * out
Definition ca-c-api.h:120
Contiguous array of bits.
Definition bitArray.H:201
void load(std::istream &input)
Loads an array of bits from a file.
Definition bitArray.H:602
constexpr size_t size() const noexcept
Returns the dimension of the bit array.
Definition bitArray.H:346
void save(std::ostream &output) const
Saves the bit sequence in a text file.
Definition bitArray.H:560
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
STL namespace.
void print(BitArray &array)
int main()