Declaration¶
Source position: classesh.inc line 672
type
TBits = class(TObject)
public
constructor Create;
destructor Destroy;
function GetFSize : SizeInt;
procedure SetOn;
procedure Clear;
procedure Clearall;
procedure CopyBits;
procedure AndBits;
procedure OrBits;
procedure XorBits;
procedure NotBits;
function Get : Boolean;
procedure Grow;
function Equals(Obj: TObject) : Boolean; overload;
function Equals(BitSet: TBits) : Boolean; overload;
procedure SetIndex;
function FindFirstBit : SizeInt;
function FindNextBit : SizeInt;
function FindPrevBit : SizeInt;
function Find : SizeInt;
function FindRev : SizeInt;
function Find0 : SizeInt;
function Find0Rev : SizeInt;
function Find1 : SizeInt;
function Find1Rev : SizeInt;
function OpenBit : SizeInt;
property Bits[Bit : SizeInt = Int64]: Boolean; {rw}
property Size: SizeInt; {rw}
class procedure MoveRange(SrcBf: TBits; SrcPos: SizeInt; DstBf: TBits;
DstPos: SizeInt; Count: SizeInt);
procedure MoveRange(SrcPos: SizeInt; DstPos: SizeInt; Count: SizeInt);
function GetUint : Cardinal;
procedure SetUint;
procedure NotRange;
procedure AndRange;
procedure OrRange;
procedure XorRange;
procedure AndNotRange;
procedure OpRange;
procedure ClearRange;
procedure SetRange;
function PopCount : SizeInt;
function IntersectionPopCount : SizeInt;
function HasIntersection : Boolean;
function DumpBinary : SizeInt;
function LoadBinary : SizeInt;
function DumpText(Pos: SizeInt; Count: SizeInt; const S0: string;
const S1: string; Buf: PChar; BufAvail: SizeInt)
: SizeInt;
function DumpText(Pos: SizeInt; Count: SizeInt; const S0: string;
const S1: string) : string;
function LoadText(Pos: SizeInt; Count: SizeInt; const S0: string;
const S1: string; Buf: PChar; BufAvail: SizeInt)
: SizeInt;
procedure LoadText(Pos: SizeInt; Count: SizeInt; const S0: string;
const S1: string; const Src: string);
end;
Description¶
TBits can be used to store collections of bits in an indexed array. This is especially useful for storing collections of booleans: Normally the size of a boolean is the size of the smallest enumerated type, i.e. 1 byte. Since a bit can take 2 values it can be used to store a boolean as well. Since TBits can store 8 bits in a byte, it takes 8 times less space to store an array of booleans in a TBits class then it would take to store them in a conventional array.
TBits introduces methods to store and retrieve bit values, apply masks, and search for bits.
Properties¶
| Member | Visibility | Description |
|---|---|---|
| Bits | public | Access to all bits in the array. |
| Size | public | Current size of the array of bits. |
Methods¶
| Member | Visibility | Description |
|---|---|---|
| AndBits | public | Performs an and operation on the bits. |
| AndNotRange | public | |
| AndRange | public | |
| Clear | public | Clears a particular bit. |
| Clearall | public | Clears all bits in the array. |
| ClearRange | public | |
| CopyBits | public | Copy bits from one bits set to another. |
| Create | public | Creates a new bits collection. |
| Destroy | public | Destroys a bit collection. |
| DumpBinary | public | |
| DumpText | public | |
| Equals | public | Determines whether the bits of 2 arrays are equal. |
| Find | public | |
| Find0 | public | |
| Find0Rev | public | |
| Find1 | public | |
| Find1Rev | public | |
| FindFirstBit | public | Find first bit with a particular value. |
| FindNextBit | public | Searches the next bit with a particular value. |
| FindPrevBit | public | Searches the previous bit with a particular value. |
| FindRev | public | |
| Get | public | Retrieve the value of a particular bit. |
| GetFSize | public | Returns the number of records used to store the bits. |
| GetUint | public | |
| Grow | public | Expands the bits array to the requested size. |
| HasIntersection | public | |
| IntersectionPopCount | public | |
| LoadBinary | public | |
| LoadText | public | |
| MoveRange | public | |
| NotBits | public | Performs a not operation on the bits. |
| NotRange | public | |
| OpenBit | public | Returns the position of the first bit that is set to False. |
| OpRange | public | |
| OrBits | public | Performs an or operation on the bits. |
| OrRange | public | |
| PopCount | public | |
| SetIndex | public | Sets the start position for FindNextBit and FindPrevBit. |
| SetOn | public | Turn a particular bit on. |
| SetRange | public | |
| SetUint | public | |
| XorBits | public | Performs a xor operation on the bits. |
| XorRange | public |