37#include "DGtal/base/Common.h"
38#include "DGtal/base/Labels.h"
43template <
typename Container1,
typename Container2>
45isEqual( Container1 & c1, Container2 & c2 )
47 if ( c1.size() == c2.size() )
49 for (
unsigned int i = 0; i < c1.size(); ++i )
51 if ( c1.test( i ) != c2.test( i ) )
59template <
typename VContainer1,
typename LContainer2>
60void insert( VContainer1 & c1, LContainer2 & c2,
unsigned int idx )
66template <
typename VContainer1,
typename LContainer2>
71 for (
unsigned int i = 0; i < nb; ++i )
73 unsigned int idx = rand() % ( l.size() );
79template <
typename VContainer1,
typename LContainer2>
80void erase( VContainer1 & c1, LContainer2 & c2,
unsigned int idx )
86template <
typename VContainer1,
typename LContainer2>
91 for (
unsigned int i = 0; i < nb; ++i )
93 unsigned int idx = rand() % ( l.size() );
103 typedef MyLabels::ConstIterator LabelsConstIterator;
104 typedef std::bitset<80> MyBitset;
109 unsigned int nbok = 0;
113 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
114 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
117 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
118 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
124 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
125 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
127 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
128 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
130 ++nb; nbok +=
isEqual( v, l ) ? 1 : 0;
131 std::cout <<
"(" << nbok <<
"/" << nb <<
") l=" << l << std::endl;
132 for ( LabelsConstIterator it = l.begin(), it_end = l.end();
134 std::cout <<
" " << *it;
135 std::cout << std::endl;
141 typedef MySmallLabels::ConstIterator SmallLabelsConstIterator;
142 typedef std::bitset<32> MySmallBitset;
148 ++nb; nbok +=
isEqual( vv, ll ) ? 1 : 0;
149 std::cout <<
"(" << nbok <<
"/" << nb <<
") small_l=" << ll << std::endl;
154 ++nb; nbok +=
isEqual( vv, ll ) ? 1 : 0;
155 std::cout <<
"(" << nbok <<
"/" << nb <<
") small_l=" << ll << std::endl;
158 ++nb; nbok +=
isEqual( vv, ll ) ? 1 : 0;
159 std::cout <<
"(" << nbok <<
"/" << nb <<
") small_l=" << ll << std::endl;
163 ++nb; nbok +=
isEqual( vv, ll ) ? 1 : 0;
164 std::cout <<
"(" << nbok <<
"/" << nb <<
") small_l=" << ll << std::endl;
167 ++nb; nbok += ll.count() == 3 ? 1 : 0;
168 std::cout <<
"(" << nbok <<
"/" << nb <<
") small_l.count()=" << ll.count() << std::endl;
171 unsigned int cnt = 0;
172 for ( SmallLabelsConstIterator it = ll.begin(), it_end = ll.end(); it != it_end; ++
cnt, ++it) {}
173 ++nb; nbok +=
cnt == 3 ? 1 : 0;
174 std::cout <<
"(" << nbok <<
"/" << nb <<
") small_l bit count with iterators=" <<
cnt << std::endl;
178 return ( nb == nbok ) ? 0 : 1;
Aim: Stores a set of labels in {O..L-1} as a sequence of bits.
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
Go to http://www.sgi.com/tech/stl/ForwardIterator.html.
void erase(VContainer1 &c1, LContainer2 &c2, unsigned int idx)
void insert(VContainer1 &c1, LContainer2 &c2, unsigned int idx)
bool isEqual(Container1 &c1, Container2 &c2)
bool checkInsert(VContainer1 &v, LContainer2 &l, unsigned int nb)
bool checkErase(VContainer1 &v, LContainer2 &l, unsigned int nb)