1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
samba-mirror/source4/torture/local
Douglas Bagnall 5235f1facf util/binsearch: macro for greater than or equal search
Sometimes you want to find the place where an item would be in a
sorted list, whether or not it is actually there.

The BINARY_ARRAY_SEARCH_GTE macro takes an extra 'next' pointer
argument over the other binsearch macros. This will end up pointing to
the next element in the case where there is not an exact match, or
NULL when there is. That is, searching the list

     { 2, 3, 4, 4, 9}

with a standard integer compare should give the following results:

search term    *result    *next
         1      -          2
         3      3          -
         4      4 [1]      -
         7      -          9
         9      9          -
        10      -          - [2]

Notes
[1] There are two fours, but you will always get the first one.
[2] The both NULL case means the search term is beyond the last list
item.

You can safely use the same pointer for both 'result' and 'next', if
you don't care to distinguish between the 'greater-than' and 'equals'
cases.

There is a torture test for this.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-09 10:32:16 +01:00
..
dbspeed.c lib: Remove tdb_compat 2015-03-17 11:30:52 +01:00
fsrvp_state.c dlist: remove unneeded type argument from DLIST_ADD_END() 2016-02-06 21:48:17 +01:00
local.c util/binsearch: macro for greater than or equal search 2016-03-09 10:32:16 +01:00
nss_tests.c s4: fix linking smbtorture on Solaris. 2015-10-06 19:15:22 +02:00
torture.c s4:torture/local: add missing #include "torture/local/proto.h" 2014-04-02 09:03:45 +02:00
verif_trailer.c torture: include config.h before any glibc headers 2015-07-17 04:41:13 +02:00
wscript_build util/binsearch: macro for greater than or equal search 2016-03-09 10:32:16 +01:00