The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bit::Util - Utility subroutines for bit-vector manipulation

SYNOPSIS

  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);

DESCRIPTION

This module provides some utility methods for bit-vector handling.

It is writting in XS and so its aim is to be very fast.

EXPORTABLE FUNCTIONS

bu_count($vec [, $start [, $end]])

Counts the number of bits set in the bit-vector.

$start and $end, when given, allows to select a sub range of bits inside the bit-vector. The bits at offsets bigger or equal than $start and smaller than $end will be counted.

bu_first($vec [, $start])

Returns the index of the first bit set in the bit-vector.

If $start is 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.

If $end is given it will start the search at the given index.

SEE ALSO

"vec" in perlfunc

AUTHOR

Salvador Fandino

COPYRIGHT AND LICENSE

Copyright (C) 2010, 2012 by Salvador Fandino, <sfandino@yahoo.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.