本文整理汇总了PHP中Region::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP Region::isEmpty方法的具体用法?PHP Region::isEmpty怎么用?PHP Region::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Region
的用法示例。
在下文中一共展示了Region::isEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(array $diffs, $originalFileName = '', $newFileName = '', $originalTimestamp = '', $newTimestamp = '', $contextLines = 1)
{
$this->diffs = $diffs;
$this->originalFileName = $originalFileName;
$this->newfileName = $newFileName;
$this->originalTimetamp = $originalTimestamp;
$this->newTimestamp = $newTimestamp;
$this->contextLines = $contextLines >= 1 ? $contextLines : 1;
for ($currentChunk = 0; $currentChunk < count($this->diffs); $currentChunk++) {
$this->regionMap[$currentChunk] = 0;
}
for ($currentChunk = 0; $currentChunk < count($this->diffs); $currentChunk++) {
if ($this->diffs[$currentChunk] instanceof AddDiff || $this->diffs[$currentChunk] instanceof DeleteDiff) {
$this->regionMap[$currentChunk] = 1;
for ($currentRegion = max($currentChunk - $this->contextLines, 0); $currentRegion < $currentChunk; $currentRegion++) {
$this->regionMap[$currentRegion] = 1;
}
for ($currentRegion = min($currentChunk + $this->contextLines, count($this->diffs)); $currentRegion > $currentChunk; $currentRegion--) {
$this->regionMap[$currentRegion] = 1;
}
}
}
$region = new Region();
for ($currentRegion = 0; $currentRegion < count($this->diffs); $currentRegion++) {
if ($this->regionMap[$currentRegion] == 1) {
$region->addDiff($this->diffs[$currentRegion]);
} else {
if (!$region->isEmpty()) {
$this->regions[$this->regionsArrayPointer++] = $region;
$region = new Region();
}
}
}
if (!$region->isEmpty()) {
$this->regions[$this->regionsArrayPointer++] = $region;
}
}