summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/arrayop.h
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-06-08 13:46:05 +0000
committerKarl Berry <karl@freefriends.org>2010-06-08 13:46:05 +0000
commita960e44eb527236f39aec81babc0474911a86078 (patch)
tree9950eca71791d90820a80a521a7cc252c0955db5 /Build/source/utils/asymptote/arrayop.h
parent6443467452320c296faa1f43f0606a9457bd4463 (diff)
asy 1.96
git-svn-id: svn://tug.org/texlive/trunk@18817 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/arrayop.h')
-rw-r--r--Build/source/utils/asymptote/arrayop.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/Build/source/utils/asymptote/arrayop.h b/Build/source/utils/asymptote/arrayop.h
index 7832c1f64dc..dd21a80a1d6 100644
--- a/Build/source/utils/asymptote/arrayop.h
+++ b/Build/source/utils/asymptote/arrayop.h
@@ -289,18 +289,16 @@ void sortArray2(vm::stack *s)
s->push(c);
}
-// Search a sorted ordered array of n elements to find an interval containing
-// a given key. Returns n-1 if the key is greater than or equal to the last
-// element, -1 if the key is less than the first element, and otherwise the
-// index corresponding to the left-hand endpoint of the matching interval.
+// Search a sorted ordered array a of n elements for key, returning the index i
+// if a[i] <= key < a[i+1], -1 if key is less than all elements of a, or
+// n-1 if key is greater than or equal to the last element of a.
template<class T>
void searchArray(vm::stack *s)
{
T key=pop<T>(s);
array *a=pop<array*>(s);
Int size=(Int) a->size();
- if(size == 0) {s->push(0); return;}
- if(key < read<T>(a,0)) {s->push(-1); return;}
+ if(size == 0 || key < read<T>(a,0)) {s->push(-1); return;}
Int u=size-1;
if(key >= read<T>(a,u)) {s->push(u); return;}
Int l=0;