containers/ | |
License | Copyright © 2007-2011, FreeBASIC Extended Library Development Group |
ext | |
BitArray | Represents an arbitrarily long bitfield. |
Functions | |
default constructor | Creates a uninitialized bitfield. |
constructor | Creates a bitfield containing a number of bits. |
isset | Determines if the specified bit is set or not. |
toggle | Toggles the value of a certain bit. |
set | Sets the value of a certain bit to 1 or on. |
reset | Sets the value of a certain bit to 0 or off. |
load | Loads a string containing a bitfield into memory. |
dump | Converts the in memory bitfield into a binary string |
size | Used to set the initial size of the bitfield, will not work if the num constructor is used. |
Examples | |
BitArray and You |
Copyright © 2007-2011, FreeBASIC Extended Library Development Group
Distributed under the FreeBASIC Extended Library Group license. See accompanying file LICENSE.txt or copy at http://code.google.com
Represents an arbitrarily long bitfield. Similiar to the C++ STL class bitset in that you cannot change its size once created.
Functions | |
default constructor | Creates a uninitialized bitfield. |
constructor | Creates a bitfield containing a number of bits. |
isset | Determines if the specified bit is set or not. |
toggle | Toggles the value of a certain bit. |
set | Sets the value of a certain bit to 1 or on. |
reset | Sets the value of a certain bit to 0 or off. |
load | Loads a string containing a bitfield into memory. |
dump | Converts the in memory bitfield into a binary string |
size | Used to set the initial size of the bitfield, will not work if the num constructor is used. |
Examples | |
BitArray and You |
#include once "ext/containers/bitarray.bi" #include once "ext/strings.bi" var bitstring = ext.strings.repeat("10", 64) ext.strings.shuffle(bitstring) var bitarray = ext.BitArray(len(bitstring)) bitarray.load(bitstring) print "bits: " & bitarray.dump() if bitarray.isset(0) then print "bit 0 is set" bitarray.toggle(30) bitarray.toggle(31) bitarray.toggle(32) print "bits: " & bitarray.dump()
Creates a bitfield containing a number of bits.
declare constructor( byval num as SizeType )
Determines if the specified bit is set or not.
declare function isset( byval bit_ as SizeType ) as ext.bool
Toggles the value of a certain bit.
declare sub toggle( byval bit_ as SizeType )
Sets the value of a certain bit to 1 or on.
declare sub set( byval bit_ as SizeType )
Sets the value of a certain bit to 0 or off.
declare sub reset( byval bit_ as SizeType )
Loads a string containing a bitfield into memory.
declare sub load( byref bstring as string )
Converts the in memory bitfield into a binary string
declare function dump( ) as string
Used to set the initial size of the bitfield, will not work if the num constructor is used.
declare sub size( byval num as SizeType )