diff options
Diffstat (limited to 'Common/Vector.h')
-rwxr-xr-x | Common/Vector.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Common/Vector.h b/Common/Vector.h index 984fddc1..210c385e 100755 --- a/Common/Vector.h +++ b/Common/Vector.h @@ -78,6 +78,23 @@ public: operator[](j) = temp; } + int FindInSorted(const T& item) const + { + int left = 0, right = Size(); + while (left != right) + { + int mid = (left + right) / 2; + const T& midValue = (*this)[mid]; + if (item == midValue) + return mid; + if (item < midValue) + right = mid; + else + left = mid + 1; + } + return -1; + } + void Sort(int left, int right) { if (right - left < 2) |