예제 #1
0
파일: example.php 프로젝트: nicmart/dgim
function randomCounterAndAry($windowSize, $maxInt, $maxForSameSize)
{
    $counter = new Counter($windowSize, $maxInt, $maxForSameSize);
    $ary = [];
    for ($i = 0; $i < $windowSize; $i++) {
        $rand = rand(0, $maxInt);
        $ary[] = $rand;
        $counter->input($rand);
    }
    return [$ary, $counter];
}
예제 #2
0
 public function testCount()
 {
     $counter = new Counter(7, 3);
     $counter->input(1)->input(2)->input(0)->input(1)->input(2)->input(0)->input(3);
     $this->assertSame(3, $counter->getCount(1));
     $this->assertSame(3, $counter->getCount(2));
     $this->assertSame(5, $counter->getCount(3));
     $this->assertSame(6, $counter->getCount(4));
     $this->assertSame(6, $counter->getCount(5));
     $this->assertSame(6, $counter->getCount(6));
     $this->assertSame(6, $counter->getCount(7));
 }