- Inherits from:
- Object
- Declared in:
- DBitArray.h
Object
|
+---DBitArray
Class Description
The bit array data type implements a number of methods for creating,
manipulating and checking bit sets.
- Example:
#include <stdio.h>
#include "ofc/DBitArray.h"
int main(int argc, char *argv[])
{
DBitArray *array = [DBitArray alloc];
[array init :1 :25]; // Initialise the array for values from 1..25
[array set :7]; // Set value 7 in the array
[array set :9 :20]; // Set values 9..20 in the array
[array reset :11]; // Reset value 11 in the array
[array reset :15 :18]; // Reset values 15..18 in the array
// Checking values
printf("Value 10 is %s\n", [array has :10] ? "set" : "reset");
printf("Value 8 is %s\n", [array has :8 ] ? "set" : "reset");
printf("Threre are %d values set\n", [array count]);
[array free]; // Cleanup
return 0;
}
- Last modified:
- 19-Jul-2008 (DBitArray.h)
Instance Variables
- private unsigned char *_array
- the bits for the array
- private int _min
- the minimum value in the bit array
- private int _max
- the maximum value in the bit array
- private int _size
- the size of the bit array
- Constructors
- - (DBitArray *) init
- Initialise to an empty bit array with range 0..255
- Returns:
- the object
- - (DBitArray *) init :(int) min :(int) max
- Initialise to an empty bit array
- Parameters:
- min - the minimum value in the bit array
max - the maximum value in the bit array
- Returns:
- the object
- Copy related methods
- - shallowCopy
- Do a shallow copy of the object
- Returns:
- the object
- Destructor
- - free
- Free the bit array
- Returns:
- the object
- Member methods
- - (int) max
- Return the maximum value in the bit array
- Returns:
- the maximum value
- - (int) min
- Return the minimum value in the bit array
- Returns:
- the minumum value
- Main methods
- - (DBitArray *) reset
- Reset the whole bit array
- Returns:
- the object
- - (DBitArray *) reset :(int) val
- Reset one value in the bit array
- Parameters:
- val - the value to reset
- Returns:
- the object
- - (DBitArray *) reset :(int) from :(int) to
- Reset a range of values in the bit array
- Parameters:
- from - the start of the bit set (incl.)
to - the end of the bit set (incl.)
- Returns:
- the object
- - (DBitArray *) reset :(int) from :(int) to :(unsigned) step
- Reset a range of values, stepwise in the bit array
- Parameters:
- from - the start of the bit set (incl.)
to - the end of the bit set (incl.)
step - the step for the bit set (> 0)
- Returns:
- the object
- - (DBitArray *) set :(int) val
- Set one value in the bit array
- Parameters:
- val - the value to set
- Returns:
- the object
- - (DBitArray *) set :(int) from :(int) to
- Set a range of values in the bit array
- Parameters:
- from - the start of the bit array (incl.)
to - the end of the bit array (incl.)
- Returns:
- the object
- - (DBitArray *) set :(int) from :(int) to :(unsigned) step
- Set a range of values, stepwise in the bit array
- Parameters:
- from - the start of the bit set (incl.)
to - the end of the bit set (incl.)
step - the step for the bit set (> 0)
- Returns:
- the object
- Checking methods
- - (int) count
- Count the number of values set
- Returns:
- the number of values set
- - (BOOL) has :(int) val
- Check if a value is set in the bit array
- Parameters:
- val - the value to be checked
- Returns:
- is the value set in the bit array ?
generated 06-Sep-2008 by ObjcDoc 3.0.0