public function testGetArray() { $array = new BitArray(64); $array->set(0); $array->set(63); $ints = $array->getBitArray(); $this->assertEquals(1, $ints[0]); $this->assertEquals(0x80000000, $ints[1]); }
/** * Sets a row of data from a BitArray. * * @param integer $y * @param BitArray $row * @return void */ public function setRow($y, BitArray $row) { $bits = $row->getBitArray(); for ($i = 0; $i < $this->rowSize; $i++) { $this->bits[$y * $this->rowSize + $i] = $bits[$i]; } }
/** * Makes an exclusive-or comparision on the current bit array. * * @param BitArray $other * @return void * @throws Exception\InvalidArgumentException */ public function xorBits(self $other) { $bitsLength = count($this->bits); $otherBits = $other->getBitArray(); if ($bitsLength !== count($otherBits)) { throw new Exception\InvalidArgumentException('Sizes don\'t match'); } for ($i = 0; $i < $bitsLength; $i++) { $this->bits[$i] = $this->bits[$i] ^ $otherBits[$i]; } }