Bio::EnsEMBL::Utils
BitString
Toolbar
Summary
Bio::EnsEMBL::Utils::BitString - bitstring object implementation
Package variables
No package variables defined.
Synopsis
No synopsis!
Description
This is an implementation of a bitstring object, taken from Damian
Convey's book "Object Oriented Perl".
Methods
bitcount | No description | Code |
complement | No description | Code |
get | No description | Code |
new | No description | Code |
print_me | No description | Code |
set | No description | Code |
Methods description
None available.
Methods code
sub bitcount
{ 8 * length ${$_[0]}; } |
sub complement
{ my ($self) = @_;
my $complement = ~$$self;
bless\$ complement, ref($self); } |
sub get
{ my ($self, $bitnum) = @_;
return vec($$self,$bitnum,1); } |
sub new
{ my $class = ref($_[0])||$_[0];
my $initbits = join '', map {$_?1:0} @_[1..$#_];
my $bs = pack 'b*', $initbits;
bless\$ bs, $class; } |
sub print_me
{ my ($self) = @_;
for (my $i=0; $i < $self->bitcount(); $i++)
{
print $self->get($i);
print ' ' unless ($i+1)%8;
print "\n" unless ($i+1)%64;
}
print "\n";
}
1; } |
sub set
{ my ($self, $bitnum, $newval) = @_;
vec($$self,$bitnum,1) = $newval?1:0; } |
General documentation
Copyright (c) 1999-2009 The European Bioinformatics Institute and
Genome Research Limited. All rights reserved.
This software is distributed under a modified Apache license.
For license details, please see
/info/about/code_licence.html