projects
/
dana
/
openbox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3afa20d
)
add some comments for binary search
author
Dana Jansens
<danakj@orodu.net>
Fri, 16 Apr 2010 15:46:52 +0000
(11:46 -0400)
committer
Mikael Magnusson
<mikachu@gmail.com>
Fri, 16 Apr 2010 18:56:27 +0000
(20:56 +0200)
obt/bsearch.h
patch
|
blob
|
history
diff --git
a/obt/bsearch.h
b/obt/bsearch.h
index
ca5ae5b
..
65e4268
100644
(file)
--- a/
obt/bsearch.h
+++ b/
obt/bsearch.h
@@
-23,9
+23,12
@@
G_BEGIN_DECLS
G_BEGIN_DECLS
+/*! Setup to do a binary search on an array holding elements of type @t */
#define BSEARCH_SETUP(t) \
register t l_BSEARCH, r_BSEARCH, out_BSEARCH;
#define BSEARCH_SETUP(t) \
register t l_BSEARCH, r_BSEARCH, out_BSEARCH;
+/*! Search an array @ar holding elements of type @t, starting at index @start,
+ with @size elements, looking for value @val. */
#define BSEARCH(t, ar, start, size, val) \
{ \
l_BSEARCH = (start); \
#define BSEARCH(t, ar, start, size, val) \
{ \
l_BSEARCH = (start); \
@@
-44,7
+47,10
@@
G_BEGIN_DECLS
} \
}
} \
}
+/*! Returns true if the element last searched for was found in the array */
#define BSEARCH_FOUND() (l_BSEARCH <= r_BSEARCH)
#define BSEARCH_FOUND() (l_BSEARCH <= r_BSEARCH)
+/*! Returns the position in the array at which the element last searched for
+ was found. */
#define BSEARCH_AT() (out_BSEARCH)
#define BSEARCH_AT() (out_BSEARCH)