Exemple #1
0
 /**
  * @param mixed        $key
  * @param integer      $begin
  * @param integer|null &$insertIndex
  *
  * @return integer|null
  */
 private function binarySearch($key, $begin = 0, &$insertIndex = null)
 {
     $comparator = $this->comparator;
     return Collection::binarySearch($this->elements, array($key, null), function ($lhs, $rhs) use($comparator) {
         return call_user_func($comparator, $lhs[0], $rhs[0]);
     }, $begin, null, $insertIndex);
 }
Exemple #2
0
 /**
  * Compare this object with another value, yielding a result according to the following table:
  *
  * +--------------------+---------------+
  * | Condition          | Result        |
  * +--------------------+---------------+
  * | $this == $value    | $result === 0 |
  * | $this < $value     | $result < 0   |
  * | $this > $value     | $result > 0   |
  * +--------------------+---------------+
  *
  * @param mixed $value The value to compare.
  *
  * @return integer                                         The result of the comparison.
  * @throws Icecave\Parity\Exception\NotComparableException Indicates that the implementation does not know how to compare $this to $value.
  */
 public function compare($value)
 {
     if (!$this->canCompare($value)) {
         throw new NotComparableException($this, $value);
     }
     return Collection::compare($this->elements, $value->elements);
 }
Exemple #3
0
 /**
  * @param mixed        $element
  * @param integer      $begin
  * @param integer|null &$insertIndex
  *
  * @return integer|null
  */
 private function binarySearch($element, $begin = 0, &$insertIndex = null)
 {
     return Collection::binarySearch($this->elements, $element, $this->comparator, $begin, null, $insertIndex);
 }