NAME

CracTools::BitVector - Full Perl BitVector implementation

VERSION

version 1.21

SYNOPSIS

my $bv = CracTools::BitVector->new(1000);

# Setting bits
my $bv->set(1);
my $bv->set(12);

# Query bits
if($bv->get(12)) {
  print STDERR "I knew this one was set!!\n";
}

DESCRIPTION

This module based implements a bitvector datastructure where individual bits can be set, unset and check. It also implement "rank", "select" functions, but it is poorly optimised.

SEE ALSO

You may want to check CracTools::GenomeMask that uses this BitVector implementation to define a complete bitset over a genome.

METHODS

new

Arg [1] : Integer - lenght of the bitvector

Description : Return a new CracTools::BitVector object
ReturnType  : CracTools::BitVector

firstBitSet

Description : Return the position of the first bit set
ReturnType  : Integer

copy

Description : Return a copy of the curent bitvector
ReturnType  : CracTools::BitVector

set

Arg [1] : Integer - position in the bitvector

Description : Set 1-bit at position i
ReturnType  : undef

unset

Arg [1] : Integer - position in the bitvector

Description : Unset 1-bit at position i
ReturnType  : undef

get

Arg [1] : Integer - position in the bitvector

Description : Return the value of the bit at position i
ReturnType  : Boolean

prev

Arg [1] : Integer - position in the bitvector
Arg [2] : (Optional) Integer - max shift from i

Description : Return the previous position that has a bit set.
              ie. a position j <= i such that get(j) == 1
              && get(k) == 0 , j < k <= i
              If max is set, j >= i - max
              -1 if no such position exists
ReturnType  : Integer

succ

Arg [1] : Integer - position in the bitvector
Arg [2] : (Optional) Integer - max shift from i

Description : Return the next position that has a bit set.
              ie. a position j >= i such that get(j) == 1
              && get(k) == 0 , j > k >= i
              If max is set, j <= i + max
              -1 if no such position exists
ReturnType  : Integer

rank

Arg [1] : Integer - position in the bitvector

Description : Return the number of bit set up to
              position i
ReturnType  : Integer

select

Arg [1] : Integer - position in the bitvector

Description : Return the next position that has a bit set.
              ie. a position j >= i such that get(j) == 1
              && get(k) == 0 , j > k >= i
              If max is set, j <= i + max
              -1 if no such position exists
ReturnType  : Integer

length

Description : Return the length of the bitvector
ReturnType  : Integer

nbSet

Description : Return the number of bit set
ReturnType  : Integer

alias: nb_set

toString

Arg [1] : (Optional) String - Separator character (space by default)

Description : Return a string representation of the bitvector
              where each bit is separated with a space character.
ReturnType  : String

alias: to_string

AUTHORS

  • Nicolas PHILIPPE <nphilippe.research@gmail.com>

  • Jérôme AUDOUX <jaudoux@cpan.org>

  • Sacha BEAUMEUNIER <sacha.beaumeunier@gmail.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by IRMB/INSERM (Institute for Regenerative Medecine and Biotherapy / Institut National de la Santé et de la Recherche Médicale) and AxLR/SATT (Lanquedoc Roussilon / Societe d'Acceleration de Transfert de Technologie).

This is free software, licensed under:

The GNU Affero General Public License, Version 3, November 2007