EstervQrCode 2.0.0
Library for qr code manipulation
Loading...
Searching...
No Matches
dynamic_bitset.h
1/***********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved.
5 * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved.
6 *
7 * THE BSD LICENSE
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *************************************************************************/
30
31/***********************************************************************
32 * Author: Vincent Rabaud
33 *************************************************************************/
34
35#ifndef OPENCV_FLANN_DYNAMIC_BITSET_H_
36#define OPENCV_FLANN_DYNAMIC_BITSET_H_
37
39
40#ifndef FLANN_USE_BOOST
41# define FLANN_USE_BOOST 0
42#endif
43//#define FLANN_USE_BOOST 1
44#if FLANN_USE_BOOST
45#include <boost/dynamic_bitset.hpp>
46typedef boost::dynamic_bitset<> DynamicBitset;
47#else
48
49#include <limits.h>
50
51#include "dist.h"
52
53namespace cvflann {
54
59class DynamicBitset
60{
61public:
64 DynamicBitset() : size_(0)
65 {
66 }
67
71 DynamicBitset(size_t sz)
72 {
73 resize(sz);
74 reset();
75 }
76
79 void clear()
80 {
81 std::fill(bitset_.begin(), bitset_.end(), 0);
82 }
83
87 bool empty() const
88 {
89 return bitset_.empty();
90 }
91
94 void reset()
95 {
96 std::fill(bitset_.begin(), bitset_.end(), 0);
97 }
98
101 void reset(size_t index)
102 {
103 bitset_[index / cell_bit_size_] &= ~(size_t(1) << (index % cell_bit_size_));
104 }
105
111 void reset_block(size_t index)
112 {
113 bitset_[index / cell_bit_size_] = 0;
114 }
115
118 void resize(size_t sz)
119 {
120 size_ = sz;
121 bitset_.resize(sz / cell_bit_size_ + 1);
122 }
123
127 void set(size_t index)
128 {
129 bitset_[index / cell_bit_size_] |= size_t(1) << (index % cell_bit_size_);
130 }
131
134 size_t size() const
135 {
136 return size_;
137 }
138
143 bool test(size_t index) const
144 {
145 return (bitset_[index / cell_bit_size_] & (size_t(1) << (index % cell_bit_size_))) != 0;
146 }
147
148private:
149 std::vector<size_t> bitset_;
150 size_t size_;
151 static const unsigned int cell_bit_size_ = CHAR_BIT * sizeof(size_t);
152};
153
154} // namespace cvflann
155
156#endif
157
159
160#endif // OPENCV_FLANN_DYNAMIC_BITSET_H_
T fill(T... args)
int index
Definition core_c.h:634
CvSize size
Definition core_c.h:112
CV_EXPORTS_W void resize(InputArray src, OutputArray dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR)
Resizes an image.
Definition flann.hpp:60
QTextStream & reset(QTextStream &stream)