Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Common/Vector.h')
-rwxr-xr-xCommon/Vector.h17
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)