2
Copyright(c) 2002-2005 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)
4
Permission is hereby granted, free of charge, to any person
5
obtaining a copy of this software and associated documentation
6
files (the "Software"), to deal in the Software without restriction,
7
including without limitation the rights to use, copy, modify, merge,
8
publish, distribute, sublicense, and/or sell copies of the Software,
9
and to permit persons to whom the Software is furnished to do so,
10
subject to the following conditions:
12
The above copyright notice and this permission notice shall be included
13
in all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
OTHER DEALINGS IN THE SOFTWARE.
24
/** \example sample5.cpp
25
Example demonstrates using enumerators - the fastest way to retrieve
26
indexes of 1 bits from the bitvector. This approach works faster than
27
get_first/get_next functions.
29
\sa bm::bvector<>::enumerator
31
For more information please visit: http://bmagic.sourceforge.net
41
void Print(unsigned n)
54
bm::bvector<>::enumerator en = bv.first();
55
bm::bvector<>::enumerator en_end = bv.end();
60
++en; // Fastest way to increment enumerator
65
// This is not the fastest way to do the job, because for_each
66
// often will try to calculate difference between iterators,
67
// which is expensive for enumerators.
68
// But it can be useful for some STL loyal applications.
70
std::for_each(en, en_end, Print);
2
Copyright(c) 2002-2005 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)
4
Permission is hereby granted, free of charge, to any person
5
obtaining a copy of this software and associated documentation
6
files (the "Software"), to deal in the Software without restriction,
7
including without limitation the rights to use, copy, modify, merge,
8
publish, distribute, sublicense, and/or sell copies of the Software,
9
and to permit persons to whom the Software is furnished to do so,
10
subject to the following conditions:
12
The above copyright notice and this permission notice shall be included
13
in all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
OTHER DEALINGS IN THE SOFTWARE.
24
/** \example sample5.cpp
25
Example demonstrates using enumerators - the fastest way to retrieve
26
indexes of 1 bits from the bitvector. This approach works faster than
27
get_first/get_next functions.
29
\sa bm::bvector<>::enumerator
31
For more information please visit: http://bmagic.sourceforge.net
41
void Print(unsigned n)
54
bm::bvector<>::enumerator en = bv.first();
55
bm::bvector<>::enumerator en_end = bv.end();
60
++en; // Fastest way to increment enumerator
65
// This is not the fastest way to do the job, because for_each
66
// often will try to calculate difference between iterators,
67
// which is expensive for enumerators.
68
// But it can be useful for some STL loyal applications.
70
std::for_each(en, en_end, Print);