public function filterByPrefix($prefixFilter)
{
$pointcuts = array_keys($this->classNames);
$result = new ClassNameIndex();
$right = count($pointcuts) - 1;
$left = 0;
$found = false;
$currentPosition = -1;
while ($found === false) {
if ($left > $right) {
break;
}
$currentPosition = $left + floor(($right - $left) / 2);
if (strpos($pointcuts[$currentPosition], $prefixFilter) === 0) {
$found = true;
break;
} else {
$comparisonResult = strcmp($prefixFilter, $pointcuts[$currentPosition]);
if ($comparisonResult > 0) {
$left = $currentPosition + 1;
} else {
$right = $currentPosition - 1;
}
}
}
if ($found === true) {
$startIndex = $currentPosition;
while ($startIndex >= 0 && strpos($pointcuts[$startIndex], $prefixFilter) === 0) {
$startIndex--;
}
$startIndex++;
$endIndex = $currentPosition;
while ($endIndex < count($pointcuts) && strpos($pointcuts[$endIndex], $prefixFilter) === 0) {
$endIndex++;
}
$result->setClassNames(array_slice($pointcuts, $startIndex, $endIndex - $startIndex));
}
return $result;
}