stanley-king 8 years ago
parent
commit
f3be653f4a
1 changed files with 12 additions and 2 deletions
  1. 12 2
      helper/search/util.php

+ 12 - 2
helper/search/util.php

@@ -263,15 +263,25 @@ class valtokey
 
     public function findless($val,$start,$length)
     {
-        $pos = algorithm::upper_bound($this->mValMap,$val);
-        $pos = $pos - $start;
+        $pos = algorithm::lower_bonud($this->mValMap,$val);
         if($pos < 0) {
             return false;
         }
         elseif ($pos >= $this->mCount) {
             $pos = $this->mCount - 1;
         }
+        else {
+            $data = $this->mValMap[$pos];
+            if($data > $val) {
+                $pos -= 1;
+            }
+        }
 
+        $pos = $pos - $start;
+        if($pos < 0) {
+            return false;
+        }
+        
         $result = [];
         for ($i = $pos; $i >= 0 && $length > 0; $i--,$length--) {
             $result[] = $this->mKeys[$i];