:goberserk:

This commit is contained in:
smiley
2015-12-03 04:19:46 +01:00
parent 20649ec13a
commit 514f95c742
20 changed files with 685 additions and 1028 deletions
+4 -28
View File
@@ -19,12 +19,12 @@ class BitBuffer{
/**
* @var array
*/
protected $buffer = [];
public $buffer = [];
/**
* @var int
*/
protected $length = 0;
public $length = 0;
/**
*
@@ -34,43 +34,19 @@ class BitBuffer{
$this->length = 0;
}
/**
* @return array
*/
public function getBuffer(){
return $this->buffer;
}
/**
* @return int
*/
public function getLengthInBits(){
return $this->length;
}
/**
* @return string
*/
public function __toString(){
$buffer = '';
$count = $this->getLengthInBits();
for($i = 0; $i < $count; $i++){
$buffer .= $this->get($i) ? '1' : '0';
for($i = 0; $i < $this->length; $i++){
$buffer .= (string)(int)(($this->buffer[(int)floor($i / 8)] >> (7 - $i % 8))&1) === 1;
}
return $buffer;
}
/**
* @param $index
*
* @return bool
*/
public function get($index){
return (($this->buffer[(int)floor($index / 8)] >> (7 - $index % 8))&1) === 1;
}
/**
* @param $num
* @param $length