datatable.directory codebase
https://datatable.directory/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
597 B
32 lines
597 B
<?php
|
|
|
|
|
|
namespace App\Tables;
|
|
|
|
use App\Models\Row;
|
|
|
|
class RowNumerator
|
|
{
|
|
/** @var int */
|
|
private $next;
|
|
/** @var int */
|
|
private $last;
|
|
|
|
/**
|
|
* Create a numerator for the given number of rows.
|
|
*
|
|
* @param int $capacity
|
|
*/
|
|
public function __construct($capacity)
|
|
{
|
|
list($this->next, $this->last) = Row::allocateRowIDs($capacity);
|
|
}
|
|
|
|
public function next()
|
|
{
|
|
if ($this->next > $this->last)
|
|
throw new \OutOfBoundsException("Row numerator has run out of allocated GRID slots");
|
|
|
|
return $this->next++;
|
|
}
|
|
}
|
|
|