Unit 'Classes' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

TBits

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Class to store collections of bits (binary values that can be 0 or 1).

Declaration

Source position: classesh.inc line 667

type TBits = class(TObject)

public

  constructor Create(); virtual;

  

Creates a new bits collection.

  destructor Destroy; override;

  

Destroys a bit collection.

  function GetFSize;

  

Returns the number of records used to store the bits.

  procedure SetOn();

  

Turn a particular bit on.

  procedure Clear();

  

Clears a particular bit.

  procedure Clearall;

  

Clears all bits in the array.

  procedure CopyBits();

  

Copy bits from one bits set to another.

  procedure AndBits();

  

Performs an and operation on the bits.

  procedure OrBits();

  

Performs an or operation on the bits.

  procedure XorBits();

  

Performs a xor operation on the bits.

  procedure NotBits();

  

Performs a not operation on the bits.

  function Get();

  

Retrieve the value of a particular bit.

  procedure Grow();

  

Expands the bits array to the requested size.

  function Equals();

  

Determines whether the bits of 2 arrays are equal.

  procedure SetIndex();

  

Sets the start position for FindNextBit and FindPrevBit.

  function FindFirstBit();

  

Find first bit with a particular value.

  function FindNextBit;

  

Searches the next bit with a particular value.

  function FindPrevBit;

  

Searches the previous bit with a particular value.

  function OpenBit;

  

Returns the position of the first bit that is set to False.

  property Bits []: Boolean; default; [rw]

  

Access to all bits in the array.

  property Size: SizeInt; [rw]

  

Current size of the array of bits.

end;

Inheritance

TBits

  

Class to store collections of bits (binary values that can be 0 or 1).

|

TObject

  

Base class of all classes.

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.


Documentation generated on: Oct 27 2024