Class Twiddling

Description

A utility class to perform bit twiddling on integers.

Located in /Twiddling.php (line 47)


	
			
Method Summary
static integer clearBit (integer $integer, integer $position)
static integer clearBits (integer $integer, integer $bits)
static integer enableBit (integer $integer, integer $position)
static integer enableBits (integer $integer, integer $bits)
static integer getMask (integer $start, integer $end)
static integer getValue (integer $integer, integer $start, integer $end)
static integer setBit (integer $integer, integer $position, boolean $on)
static integer setBits (integer $integer, integer $bits, boolean $on)
static integer setValue (integer $integer, integer $start, integer $end, integer $value)
static boolean testAllBits (integer $integer, integer $bits)
static boolean testAnyBits (integer $integer, integer $bits)
static boolean testBit (integer $integer, integer $position)
static integer toggleBit (integer $integer, integer $position)
static integer toggleBits (integer $integer, integer $bits)
Methods
static method clearBit (line 87)

Clears a bit at a given position in an integer.

  • access: public
static integer clearBit (integer $integer, integer $position)
  • integer $integer: The value to manipulate.
  • integer $position: The position of the bit to clear.
static method clearBits (line 149)

Clears a given set of bits in an integer.

  • access: public
static integer clearBits (integer $integer, integer $bits)
  • integer $integer: The value to manipulate.
  • integer $bits: The bits to clear.
static method enableBit (line 75)

Enables a bit at a given position in an integer.

  • access: public
static integer enableBit (integer $integer, integer $position)
  • integer $integer: The value to manipulate.
  • integer $position: The position of the bit to enable.
static method enableBits (line 137)

Enables a given set of bits in an integer.

  • access: public
static integer enableBits (integer $integer, integer $bits)
  • integer $integer: The value to manipulate.
  • integer $bits: The bits to enable.
static method getMask (line 228)

Returns an integer with all bits set from start to end.

  • access: public
static integer getMask (integer $start, integer $end)
  • integer $start: The position to start setting bits from. Must be <= $end.
  • integer $end: The position to stop setting bits. Must be >= $start.
static method getValue (line 215)

Retrieves a value from a given range in an integer, inclusive.

  • access: public
static integer getValue (integer $integer, integer $start, integer $end)
  • integer $integer: The value to read from.
  • integer $start: The position to read from. Must be <= $end.
  • integer $end: The position to read to. Must be >= $start.
static method setBit (line 62)

Sets a bit at a given position in an integer.

  • access: public
static integer setBit (integer $integer, integer $position, boolean $on)
  • integer $integer: The value to manipulate.
  • integer $position: The position of the bit to set.
  • boolean $on: Whether to enable or clear the bit.
static method setBits (line 124)

Sets a given set of bits in an integer.

  • access: public
static integer setBits (integer $integer, integer $bits, boolean $on)
  • integer $integer: The value to manipulate.
  • integer $bits: The bits to set.
  • boolean $on: Whether to enable or clear the bits.
static method setValue (line 201)

Stores a value in a given range in an integer.

  • access: public
static integer setValue (integer $integer, integer $start, integer $end, integer $value)
  • integer $integer: The value to store into.
  • integer $start: The position to store from. Must be <= $end.
  • integer $end: The position to store to. Must be >= $start.
  • integer $value: The value to store.
static method testAllBits (line 174)

Tests a given set of bits in an integer returning whether all bits are set.

  • access: public
static boolean testAllBits (integer $integer, integer $bits)
  • integer $integer: The value to test.
  • integer $bits: The bits to test.
static method testAnyBits (line 187)

Tests a given set of bits in an integer returning whether any bits are set.

  • access: public
static boolean testAnyBits (integer $integer, integer $bits)
  • integer $integer: The value to test.
  • integer $bits: The bits to test.
static method testBit (line 111)

Tests a bit at a given position in an integer.

  • access: public
static boolean testBit (integer $integer, integer $position)
  • integer $integer: The value to test.
  • integer $position: The position of the bit to test.
static method toggleBit (line 99)

Toggles a bit at a given position in an integer.

  • access: public
static integer toggleBit (integer $integer, integer $position)
  • integer $integer: The value to manipulate.
  • integer $position: The position of the bit to toggle.
static method toggleBits (line 161)

Toggles a given set of bits in an integer.

  • access: public
static integer toggleBits (integer $integer, integer $bits)
  • integer $integer: The value to manipulate.
  • integer $bits: The bits to toggle.

Documentation generated on Fri, 05 Sep 2008 20:20:06 +0300 by phpDocumentor 1.4.1