Bit::Util - Utility subroutines for bit-vector manipulation
use Bit::Util qw(bu_count bu_last bu_first); my $vec = "foobardoz"; my $cnt = bu_count($vec); my $first = bu_first($vec); my $last = bu_last($vec);
This module provides some utility methods for bit-vector handling.
It is writting in XS and so its aim is to be very fast.
- bu_count($vec [, $start [, $end]])
Counts the number of bits set in the bit-vector.
$end, when given, allows to select a sub range of bits inside the bit-vector. The bits at offsets bigger or equal than
$startand smaller than
$endwill be counted.
- bu_first($vec [, $start])
Returns the index of the first bit set in the bit-vector.
$startis given it will start the search at the given index.
- bu_last($vec [, $end])
Returns the index of the last bit set in the bit-vector.
$endis given it will start the search at the given index.
Copyright (C) 2010, 2012 by Salvador Fandino, <email@example.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.