Package ais :: Module BitVector :: Class BitVector
[hide private]
[frames] | no frames]

Class BitVector

source code

object --+
         |
        BitVector

Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_setbit(self, posn, val)
Set the bit at the designated position to the value shown
source code
 
_getbit(self, posn)
Get the bit from the designated position
source code
 
__xor__(self, other)
Take a bitwise 'xor' of the bit vector on which the method is invoked with the argument bit vector.
source code
 
__and__(self, other)
Take a bitwise 'and' of the bit vector on which the method is invoked with the argument bit vector.
source code
 
__or__(self, other)
Take a bitwise 'or' of the bit vector on which the method is invoked with the argument bit vector.
source code
 
__invert__(self)
Invert the bits in the bit vector on which the method is invoked and return the result as a new bit vector.
source code
 
__add__(self, other)
Concatenate the argument bit vector with the bit vector on which the method is invoked.
source code
 
_getsize(self)
Return the number of bits in a bit vector.
source code
 
read_bits_from_file(self, blocksize)
Read blocksize bits from a disk file and return a BitVector object containing the bits.
source code
 
read_bits_from_fileobject(self, fp)
This function is meant to read a bit string from a file like object.
source code
 
write_bits_to_fileobject(self, fp)
This function is meant to write a bit vector directly to a file like object.
source code
 
divide_into_two(self)
Divides an even-sized bit vector into two and returns the two halves as a list of two bit vectors.
source code
 
permute(self, permute_list)
Permute a bit vector according to the indices shown in the second argument list.
source code
 
unpermute(self, permute_list)
Unpermute the bit vector according to the permutation list supplied as the second argument.
source code
 
write_to_file(self, file_out)
(Contributed by Joe Davidson) Write the bitvector to the file object file_out.
source code
 
close_file_object(self)
For closing a file object that was used for reading the bits into one or more BitVector objects.
source code
 
intValue(self)
Return the integer value of a bitvector
source code
 
__lshift__(self, n)
For an in-place left circular shift by n bit positions
source code
 
__rshift__(self, n)
For an in-place right circular shift by n bit positions.
source code
 
circular_rotate_left_by_one(self)
For a one-bit in-place left circular shift
source code
 
circular_rotate_right_by_one(self)
For a one-bit in-place right circular shift
source code
 
circular_rot_left(self)
This is merely another implementation of the method circular_rotate_left_by_one() shown above.
source code
 
circular_rot_right(self)
This is merely another implementation of the method circular_rotate_right_by_one() shown above.
source code
 
__getitem__(self, posn)
Get the bit from the designated position
source code
 
__setitem__(self, posn, val)
Set the bit at the designated position to the value shown
source code
 
__getslice__(self, i, j)
Allow slicing with [i:j], [:], etc.
source code
 
__len__(self)
Return the number of bits in a bit vector.
source code
 
__int__(self)
Return the integer value of a bitvector
source code
 
__iter__(self)
To allow iterations over a bit vector by supporting the 'for bit in bit_vector' syntax:
source code
 
__str__(self)
To create a print representation
source code
 
__eq__(self, other) source code
 
__ne__(self, other) source code
 
__lt__(self, other) source code
 
__le__(self, other) source code
 
__gt__(self, other) source code
 
__ge__(self, other) source code
 
_make_deep_copy(self)
Make a deep copy of a bit vector
source code
 
_resize_pad_from_left(self, n)
Resize a bit vector by padding with n 0's from the left.
source code
 
_resize_pad_from_right(self, n)
Resize a bit vector by padding with n 0's from the right.
source code
 
pad_from_left(self, n)
Pad a bit vector with n zeros from the left
source code
 
pad_from_right(self, n)
Pad a bit vector with n zeros from the right
source code
 
__contains__(self, otherBitVec)
This supports 'if x in y' and 'if x not in y' syntax for bit vectors.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

__xor__(self, other)

source code 
Take a bitwise 'xor' of the bit vector on which the method is invoked with the argument bit vector. Return the result as a new bit vector. If the two bit vectors are not of the same size, pad the shorter one with zero's from the left.

__and__(self, other)
(And operator)

source code 
Take a bitwise 'and' of the bit vector on which the method is invoked with the argument bit vector. Return the result as a new bit vector. If the two bit vectors are not of the same size, pad the shorter one with zero's from the left.

__or__(self, other)
(Or operator)

source code 
Take a bitwise 'or' of the bit vector on which the method is invoked with the argument bit vector. Return the result as a new bit vector. If the two bit vectors are not of the same size, pad the shorter one with zero's from the left.

__add__(self, other)
(Addition operator)

source code 
Concatenate the argument bit vector with the bit vector on which the method is invoked. Return the concatenated bit vector as a new BitVector object.

read_bits_from_file(self, blocksize)

source code 
Read blocksize bits from a disk file and return a BitVector object containing the bits. If the file contains fewer bits than blocksize, construct the BitVector object from however many bits there are in the file. If the file contains zero bits, return a BitVector object of size attribute set to 0.

write_bits_to_fileobject(self, fp)

source code 
This function is meant to write a bit vector directly to a file like object. Note that whereas 'write_to_file' method creates a memory footprint that corresponds exactly to the bit vector, the 'write_bits_to_fileobject' actually writes out the 1's and 0's as individual items to the file object. That makes this method convenient for creating a string representation of a bit vector, especially if you use the StringIO class, as shown in the test code.

permute(self, permute_list)

source code 
Permute a bit vector according to the indices shown in the second argument list. Return the permuted bit vector as a new bit vector.

unpermute(self, permute_list)

source code 
Unpermute the bit vector according to the permutation list supplied as the second argument. If you first permute a bit vector by using permute() and then unpermute() it using the same permutation list, you will get back the original bit vector.

write_to_file(self, file_out)

source code 
(Contributed by Joe Davidson) Write the bitvector to the file object file_out. (A file object is returned by a call to open()). Since all file I/O is byte oriented, the bitvector must be multiple of 8 bits. Each byte treated as MSB first (0th index).

circular_rot_left(self)

source code 
This is merely another implementation of the method circular_rotate_left_by_one() shown above. This one does NOT use map functions. This method carries out a one-bit left circular shift of a bit vector.

circular_rot_right(self)

source code 
This is merely another implementation of the method circular_rotate_right_by_one() shown above. This one does NOT use map functions. This method does a one-bit right circular shift of a bit vector.

__str__(self)
(Informal representation operator)

source code 
To create a print representation
Overrides: object.__str__

_resize_pad_from_left(self, n)

source code 
Resize a bit vector by padding with n 0's from the left. Return the result as a new bit vector.

_resize_pad_from_right(self, n)

source code 
Resize a bit vector by padding with n 0's from the right. Return the result as a new bit vector.