From 2b664acdb7e04fba55c51c01429bd87752522729 Mon Sep 17 00:00:00 2001 From: GrieferAtWork Date: Mon, 20 May 2024 14:46:52 +0200 Subject: [PATCH] Re-implement `Sequence.bfind` using new default API --- .vs/deemon-v141.vcxproj | 5 +- .vs/deemon-v141.vcxproj.filters | 15 +- .vs/deemon-v142.vcxproj | 5 +- .vs/deemon-v142.vcxproj.filters | 15 +- .../deemon/kos-headers/compiler/pp-generic.h | 28 +- include/deemon/kos-headers/hybrid/compiler.h | 1 + src/deemon/objects/seq.c | 476 ++++---------- src/deemon/objects/seq/bsearch-impl.c.inl | 234 ------- src/deemon/objects/seq/bsearch.c | 56 -- src/deemon/objects/seq/bsearch.c.inl | 226 ------- src/deemon/objects/seq/bsearch.h | 67 -- .../default-api-methods-attrproxy-impl.c.inl | 359 ++++++---- .../default-api-methods-bsearch-impl.c.inl | 319 +++++++++ .../default-api-methods-require-impl.c.inl | 615 ++++++++++-------- src/deemon/objects/seq/default-api-methods.c | 454 +++++++++++-- src/deemon/objects/seq/default-api.c | 4 +- src/deemon/objects/seq/default-api.h | 210 +++--- src/deemon/runtime/kwlist.h | 2 + src/deemon/runtime/strings.h | 16 + util/test/deemon-sequence-bsearch.dee | 11 +- 20 files changed, 1597 insertions(+), 1521 deletions(-) delete mode 100644 src/deemon/objects/seq/bsearch-impl.c.inl delete mode 100644 src/deemon/objects/seq/bsearch.c delete mode 100644 src/deemon/objects/seq/bsearch.c.inl delete mode 100644 src/deemon/objects/seq/bsearch.h create mode 100644 src/deemon/objects/seq/default-api-methods-bsearch-impl.c.inl diff --git a/.vs/deemon-v141.vcxproj b/.vs/deemon-v141.vcxproj index beade47ae..e27661763 100644 --- a/.vs/deemon-v141.vcxproj +++ b/.vs/deemon-v141.vcxproj @@ -241,13 +241,11 @@ - - - + @@ -430,7 +428,6 @@ - diff --git a/.vs/deemon-v141.vcxproj.filters b/.vs/deemon-v141.vcxproj.filters index 17055a28f..e896c8736 100644 --- a/.vs/deemon-v141.vcxproj.filters +++ b/.vs/deemon-v141.vcxproj.filters @@ -696,15 +696,6 @@ src\objects - - src\objects\seq - - - src\objects\seq - - - src\objects\seq - src\objects\seq @@ -717,6 +708,9 @@ src\objects\seq + + src\objects\seq + src\objects\seq @@ -1259,9 +1253,6 @@ src\objects - - src\objects\seq - src\objects\seq diff --git a/.vs/deemon-v142.vcxproj b/.vs/deemon-v142.vcxproj index 565539d72..a03119b22 100644 --- a/.vs/deemon-v142.vcxproj +++ b/.vs/deemon-v142.vcxproj @@ -241,13 +241,11 @@ - - - + @@ -430,7 +428,6 @@ - diff --git a/.vs/deemon-v142.vcxproj.filters b/.vs/deemon-v142.vcxproj.filters index 17055a28f..e896c8736 100644 --- a/.vs/deemon-v142.vcxproj.filters +++ b/.vs/deemon-v142.vcxproj.filters @@ -696,15 +696,6 @@ src\objects - - src\objects\seq - - - src\objects\seq - - - src\objects\seq - src\objects\seq @@ -717,6 +708,9 @@ src\objects\seq + + src\objects\seq + src\objects\seq @@ -1259,9 +1253,6 @@ src\objects - - src\objects\seq - src\objects\seq diff --git a/include/deemon/kos-headers/compiler/pp-generic.h b/include/deemon/kos-headers/compiler/pp-generic.h index 024efefc0..d6718ea16 100644 --- a/include/deemon/kos-headers/compiler/pp-generic.h +++ b/include/deemon/kos-headers/compiler/pp-generic.h @@ -58,20 +58,24 @@ #endif /* !__PREPROCESSOR_HAVE_STR */ #ifdef __PREPROCESSOR_HAVE_CAT -#define __PP_PRIVATE_CAT2(a, b) a##b -#define __PP_PRIVATE_CAT3(a, b, c) a##b##c -#define __PP_PRIVATE_CAT4(a, b, c, d) a##b##c##d -#define __PP_CAT2(a, b) __PP_PRIVATE_CAT2(a, b) -#define __PP_CAT3(a, b, c) __PP_PRIVATE_CAT3(a, b, c) -#define __PP_CAT4(a, b, c, d) __PP_PRIVATE_CAT4(a, b, c, d) +#define __PP_PRIVATE_CAT2(a, b) a##b +#define __PP_PRIVATE_CAT3(a, b, c) a##b##c +#define __PP_PRIVATE_CAT4(a, b, c, d) a##b##c##d +#define __PP_PRIVATE_CAT5(a, b, c, d, e) a##b##c##d##e +#define __PP_CAT2(a, b) __PP_PRIVATE_CAT2(a, b) +#define __PP_CAT3(a, b, c) __PP_PRIVATE_CAT3(a, b, c) +#define __PP_CAT4(a, b, c, d) __PP_PRIVATE_CAT4(a, b, c, d) +#define __PP_CAT5(a, b, c, d, e) __PP_PRIVATE_CAT5(a, b, c, d, e) #else /* __PREPROCESSOR_HAVE_CAT */ /* clang-format off */ -#define __PP_PRIVATE_CAT2(a, b) a/**/b -#define __PP_PRIVATE_CAT3(a, b, c) a/**/b/**/c -#define __PP_PRIVATE_CAT4(a, b, c, d) a/**/b/**/c/**/d -#define __PP_CAT2(a, b) a/**/b -#define __PP_CAT3(a, b, c) a/**/b/**/c -#define __PP_CAT4(a, b, c, d) a/**/b/**/c/**/d +#define __PP_PRIVATE_CAT2(a, b) a/**/b +#define __PP_PRIVATE_CAT3(a, b, c) a/**/b/**/c +#define __PP_PRIVATE_CAT4(a, b, c, d) a/**/b/**/c/**/d +#define __PP_PRIVATE_CAT5(a, b, c, d, e) a/**/b/**/c/**/d/**/e +#define __PP_CAT2(a, b) a/**/b +#define __PP_CAT3(a, b, c) a/**/b/**/c +#define __PP_CAT4(a, b, c, d) a/**/b/**/c/**/d +#define __PP_CAT5(a, b, c, d, e) a/**/b/**/c/**/d/**/e /* clang-format on */ #endif /* !__PREPROCESSOR_HAVE_CAT */ diff --git a/include/deemon/kos-headers/hybrid/compiler.h b/include/deemon/kos-headers/hybrid/compiler.h index 6696ba249..12a91f8e9 100644 --- a/include/deemon/kos-headers/hybrid/compiler.h +++ b/include/deemon/kos-headers/hybrid/compiler.h @@ -215,6 +215,7 @@ #define PP_CAT2 __PP_CAT2 #define PP_CAT3 __PP_CAT3 #define PP_CAT4 __PP_CAT4 +#define PP_CAT5 __PP_CAT5 #define PP_PRIVATE_MUL8 __PP_PRIVATE_MUL8 #define PP_MUL8 __PP_MUL8 diff --git a/src/deemon/objects/seq.c b/src/deemon/objects/seq.c index c9cd9f131..deae5539e 100644 --- a/src/deemon/objects/seq.c +++ b/src/deemon/objects/seq.c @@ -46,7 +46,6 @@ #include "../runtime/kwlist.h" #include "../runtime/runtime_error.h" #include "../runtime/strings.h" -#include "seq/bsearch.h" #include "seq/combinations.h" #include "seq/concat.h" #include "seq/default-api.h" @@ -3634,11 +3633,9 @@ seq_startswith(DeeObject *self, size_t argc, DeeObject *const *argv) { int result; if (DeeArg_Unpack(argc, argv, "o|o:startswith", &elem, &key)) goto err; - if (DeeNone_Check(key)) { - result = generic_seq_startswith(self, elem); - } else { - result = generic_seq_startswith_with_key(self, elem, key); - } + result = !DeeNone_Check(key) + ? generic_seq_startswith_with_key(self, elem, key) + : generic_seq_startswith(self, elem); if unlikely(result < 0) goto err; return_bool_(result); @@ -3652,11 +3649,9 @@ seq_endswith(DeeObject *self, size_t argc, DeeObject *const *argv) { int result; if (DeeArg_Unpack(argc, argv, "o|o:endswith", &elem, &key)) goto err; - if (DeeNone_Check(key)) { - result = generic_seq_endswith(self, elem); - } else { - result = generic_seq_endswith_with_key(self, elem, key); - } + result = !DeeNone_Check(key) + ? generic_seq_endswith_with_key(self, elem, key) + : generic_seq_endswith(self, elem); if unlikely(result < 0) goto err; return_bool_(result); @@ -3664,6 +3659,8 @@ seq_endswith(DeeObject *self, size_t argc, DeeObject *const *argv) { return NULL; } + +#ifndef CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS struct sequence_find_data { DeeObject *sfd_elem; /* [1..1] The element to find */ size_t sfd_start; /* Search start index */ @@ -3847,124 +3844,6 @@ get_sequence_find_args_kw(char const *__restrict name, return -1; } -struct sequence_find_data_defl { - struct sequence_find_data sfdd_data; /* Base data */ - DeeObject *sfdd_defl; /* [0..1] Default value. */ -}; - -/* (elem,key:?DCallable=!N,defl?) - * (elem,start:?Dint,key:?DCallable=!N,defl?) - * (elem,start:?Dint,end:?Dint,key:?DCallable=!N,defl?) */ -PRIVATE WUNUSED NONNULL((1, 5)) int DCALL -get_sequence_find_defl_args_kw(char const *__restrict name, - size_t argc, DeeObject *const *argv, DeeObject *kw, - struct sequence_find_data_defl *__restrict result) { - DREF DeeObject *temp; - DeeKwArgs kwargs; - if (DeeKwArgs_Init(&kwargs, &argc, argv, kw)) - goto err; - switch (argc) { - - case 0: - if unlikely((result->sfdd_data.sfd_elem = DeeKwArgs_GetItemNRStringHash(&kwargs, "elem", Dee_HashStr__elem)) == NULL) - goto err; -check_kw_start_end_key_defl: - if unlikely((temp = DeeKwArgs_GetItemNRStringHashDef(&kwargs, "start", Dee_HashStr__start, DeeInt_Zero)) == NULL) - goto err; - if (DeeObject_AsSSize(temp, (Dee_ssize_t *)&result->sfdd_data.sfd_start)) - goto err; -check_kw_end_key_defl: - if unlikely((temp = DeeKwArgs_GetItemNRStringHashDef(&kwargs, "end", Dee_HashStr__end, DeeInt_MinusOne)) == NULL) - goto err; - if (DeeObject_AsSSize(temp, (Dee_ssize_t *)&result->sfdd_data.sfd_end)) - goto err; -/*check_kw_key_defl:*/ - if unlikely((result->sfdd_data.sfd_key = DeeKwArgs_GetItemNRStringHashDef(&kwargs, "key", Dee_HashStr__key, Dee_None)) == NULL) - goto err; - if (DeeNone_Check(result->sfdd_data.sfd_key)) - result->sfdd_data.sfd_key = NULL; -check_kw_defl: - if unlikely((result->sfdd_defl = DeeKwArgs_TryGetItemNRStringHash(&kwargs, "defl", Dee_HashStr__defl)) == NULL) - goto err; - if (result->sfdd_defl == ITER_DONE) - result->sfdd_defl = NULL; - break; - - case 1: - result->sfdd_data.sfd_elem = argv[0]; - goto check_kw_start_end_key_defl; - - case 2: - result->sfdd_data.sfd_elem = argv[0]; - if (DeeInt_Check(argv[1])) { - if (DeeObject_AsSSize(argv[1], (Dee_ssize_t *)&result->sfdd_data.sfd_start)) - goto err; - goto check_kw_end_key_defl; - } - result->sfdd_data.sfd_key = argv[1]; - result->sfdd_data.sfd_start = 0; - if (DeeNone_Check(result->sfdd_data.sfd_key)) - result->sfdd_data.sfd_key = NULL; -check_kw_end_defl: - if unlikely((temp = DeeKwArgs_GetItemNRStringHashDef(&kwargs, "end", Dee_HashStr__end, DeeInt_MinusOne)) == NULL) - goto err; - if (DeeObject_AsSSize(temp, (Dee_ssize_t *)&result->sfdd_data.sfd_end)) - goto err; - goto check_kw_defl; - - case 3: - result->sfdd_data.sfd_elem = argv[0]; - if (!DeeInt_Check(argv[1])) { - /* (elem,key:?DCallable=!N,defl?) */ - result->sfdd_data.sfd_key = argv[1]; - result->sfdd_defl = argv[2]; - break; - } - if (DeeObject_AsSSize(argv[1], (Dee_ssize_t *)&result->sfdd_data.sfd_start)) - goto err; - if (DeeInt_Check(argv[2])) { - if (DeeObject_AsSSize(argv[2], (Dee_ssize_t *)&result->sfdd_data.sfd_end)) - goto err; - goto check_kw_end_key_defl; - } - result->sfdd_data.sfd_key = argv[2]; - if (DeeNone_Check(result->sfdd_data.sfd_key)) - result->sfdd_data.sfd_key = NULL; - goto check_kw_end_defl; - - case 4: - if (DeeObject_AsSSize(argv[1], (Dee_ssize_t *)&result->sfdd_data.sfd_start)) - goto err; - if (DeeObject_AsSSize(argv[2], (Dee_ssize_t *)&result->sfdd_data.sfd_end)) - goto err; - result->sfdd_data.sfd_elem = argv[0]; - result->sfdd_data.sfd_key = argv[3]; - if (DeeNone_Check(result->sfdd_data.sfd_key)) - result->sfdd_data.sfd_key = NULL; - goto check_kw_defl; - - case 5: - if (DeeObject_AsSSize(argv[1], (Dee_ssize_t *)&result->sfdd_data.sfd_start)) - goto err; - if (DeeObject_AsSSize(argv[2], (Dee_ssize_t *)&result->sfdd_data.sfd_end)) - goto err; - result->sfdd_data.sfd_elem = argv[0]; - result->sfdd_data.sfd_key = argv[3]; - if (DeeNone_Check(result->sfdd_data.sfd_key)) - result->sfdd_data.sfd_key = NULL; - result->sfdd_defl = argv[4]; - break; - - default: - err_invalid_argc(name, argc, 1, 4); - goto err; - } - return DeeKwArgs_Done(&kwargs, argc, name); -err: - return -1; -} - -#ifndef CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL seq_reversed(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { DREF DeeObject *result; @@ -4415,6 +4294,51 @@ seq_sort(DeeObject *self, size_t argc, #endif /* !CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS */ +PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL +seq_index(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { + DeeObject *item, *key = Dee_None; + size_t result, start = 0, end = (size_t)-1; + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, + "o|" UNPuSIZ UNPuSIZ "o:index", + &item, &start, &end, &key)) + goto err; + result = !DeeNone_Check(key) + ? new_DeeSeqFindWithKey(self, item, start, end, key) + : new_DeeSeqFind(self, item, start, end); + if unlikely(result == (size_t)Dee_COMPARE_ERR) + goto err; + if unlikely(result == (size_t)-1) + goto err_no_item; + return DeeInt_NewSize(result); +err_no_item: + err_item_not_found(self, item); +err: + return NULL; +} + +PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL +seq_rindex(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { + DeeObject *item, *key = Dee_None; + size_t result, start = 0, end = (size_t)-1; + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, + "o|" UNPuSIZ UNPuSIZ "o:rindex", + &item, &start, &end, &key)) + goto err; + result = !DeeNone_Check(key) + ? new_DeeSeqRFindWithKey(self, item, start, end, key) + : new_DeeSeqRFind(self, item, start, end); + if unlikely(result == (size_t)Dee_COMPARE_ERR) + goto err; + if unlikely(result == (size_t)-1) + goto err_no_item; + return DeeInt_NewSize(result); +err_no_item: + err_item_not_found(self, item); +err: + return NULL; +} + + DOC_DEF(seq_byhash_doc, "(template:?O)->?DSequence\n" "#ptemplate{The object who's hash should be used to search for collisions}" @@ -4446,201 +4370,81 @@ seq_byhash(DeeObject *self, size_t argc, } - -PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL -seq_bfind(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - size_t result; - struct sequence_find_data data; - if (get_sequence_find_args_kw("bfind", argc, argv, kw, &data)) - goto err; - if (!data.sfd_key) { - result = DeeSeq_BFind(self, data.sfd_start, data.sfd_end, data.sfd_elem, NULL); - } else { - data.sfd_elem = DeeObject_Call(data.sfd_key, 1, &data.sfd_elem); - if unlikely(!data.sfd_elem) - goto err; - result = DeeSeq_BFind(self, data.sfd_start, data.sfd_end, data.sfd_elem, data.sfd_key); - Dee_Decref(data.sfd_elem); - } - if ((Dee_ssize_t)result < 0) { - if unlikely(result == (size_t)-2) - goto err; - if unlikely(result == (size_t)-1) - return_none; - } - return DeeInt_NewSize(result); -err: - return NULL; -} - PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL seq_bcontains(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - size_t result; - struct sequence_find_data data; - if (get_sequence_find_args_kw("bcontains", argc, argv, kw, &data)) - goto err; - if (!data.sfd_key) { - result = DeeSeq_BFind(self, data.sfd_start, data.sfd_end, data.sfd_elem, NULL); - } else { - data.sfd_elem = DeeObject_Call(data.sfd_key, 1, &data.sfd_elem); - if unlikely(!data.sfd_elem) - goto err; - result = DeeSeq_BFind(self, data.sfd_start, data.sfd_end, data.sfd_elem, data.sfd_key); - Dee_Decref(data.sfd_elem); - } - if ((Dee_ssize_t)result < 0) { - if unlikely(result == (size_t)-2) - goto err; - if unlikely(result == (size_t)-1) - return_false; - } - return_true; + DeeObject *item, *key = Dee_None; + size_t result, start = 0, end = (size_t)-1; + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, + "o|" UNPuSIZ UNPuSIZ "o:bcontains", + &item, &start, &end, &key)) + goto err; + result = !DeeNone_Check(key) + ? new_DeeSeq_BFindWithKey(self, item, start, end, key) + : new_DeeSeq_BFind(self, item, start, end); + if unlikely(result == (size_t)Dee_COMPARE_ERR) + goto err; + return_bool_(result != (size_t)-1); err: return NULL; } PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL seq_bindex(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - size_t result; - struct sequence_find_data data; - if (get_sequence_find_args_kw("bindex", argc, argv, kw, &data)) + DeeObject *item, *key = Dee_None; + size_t result, start = 0, end = (size_t)-1; + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, + "o|" UNPuSIZ UNPuSIZ "o:bindex", + &item, &start, &end, &key)) goto err; - if (!data.sfd_key) { - result = DeeSeq_BFind(self, data.sfd_start, data.sfd_end, data.sfd_elem, NULL); - } else { - data.sfd_elem = DeeObject_Call(data.sfd_key, 1, &data.sfd_elem); - if unlikely(!data.sfd_elem) - goto err; - result = DeeSeq_BFind(self, data.sfd_start, data.sfd_end, data.sfd_elem, data.sfd_key); - Dee_Decref(data.sfd_elem); - } - if unlikely((Dee_ssize_t)result < 0) { - if unlikely(result == (size_t)-2) - goto err; - if unlikely(result == (size_t)-1) - goto err_not_found; - } - return DeeInt_NewSize(result); -err_not_found: - err_item_not_found(self, data.sfd_elem); -err: - return NULL; -} - -PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL -seq_bposition(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - size_t result; - struct sequence_find_data data; - if (get_sequence_find_args_kw("bposition", argc, argv, kw, &data)) + result = !DeeNone_Check(key) + ? new_DeeSeq_BFindWithKey(self, item, start, end, key) + : new_DeeSeq_BFind(self, item, start, end); + if unlikely(result == (size_t)Dee_COMPARE_ERR) goto err; - if (!data.sfd_key) { - result = DeeSeq_BFindPosition(self, data.sfd_start, data.sfd_end, data.sfd_elem, NULL); - } else { - data.sfd_elem = DeeObject_Call(data.sfd_key, 1, &data.sfd_elem); - if unlikely(!data.sfd_elem) - goto err; - result = DeeSeq_BFindPosition(self, data.sfd_start, data.sfd_end, data.sfd_elem, data.sfd_key); - Dee_Decref(data.sfd_elem); - } if unlikely(result == (size_t)-1) - goto err; + goto err_not_found; return DeeInt_NewSize(result); -err: - return NULL; -} - -PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL -seq_brange(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - int error; - size_t result_start, result_end; - struct sequence_find_data data; - if (get_sequence_find_args_kw("brange", argc, argv, kw, &data)) - goto err; - if (!data.sfd_key) { - error = DeeSeq_BFindRange(self, data.sfd_start, data.sfd_end, data.sfd_elem, NULL, &result_start, &result_end); - } else { - data.sfd_elem = DeeObject_Call(data.sfd_key, 1, &data.sfd_elem); - if unlikely(!data.sfd_elem) - goto err; - error = DeeSeq_BFindRange(self, data.sfd_start, data.sfd_end, data.sfd_elem, data.sfd_key, &result_start, &result_end); - Dee_Decref(data.sfd_elem); - } - if unlikely(error) - goto err; - return DeeTuple_Newf(PCKuSIZ PCKuSIZ, - result_start, - result_end); -err: - return NULL; -} - -PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL -seq_blocate(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - DREF DeeObject *result; - struct sequence_find_data_defl data; - if (get_sequence_find_defl_args_kw("blocate", argc, argv, kw, &data)) - goto err; - if (data.sfdd_data.sfd_key == NULL) { - result = DeeSeq_BLocate(self, data.sfdd_data.sfd_start, data.sfdd_data.sfd_end, - data.sfdd_data.sfd_elem, NULL, data.sfdd_defl); - } else { - data.sfdd_data.sfd_elem = DeeObject_Call(data.sfdd_data.sfd_key, 1, &data.sfdd_data.sfd_elem); - if unlikely(!data.sfdd_data.sfd_elem) - goto err; - result = DeeSeq_BLocate(self, data.sfdd_data.sfd_start, data.sfdd_data.sfd_end, - data.sfdd_data.sfd_elem, data.sfdd_data.sfd_key, data.sfdd_defl); - Dee_Decref(data.sfdd_data.sfd_elem); - } - return result; +err_not_found: + err_item_not_found(self, item); err: return NULL; } PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL seq_blocateall(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - int error; - size_t result_start, result_end; - struct sequence_find_data data; - if (get_sequence_find_args_kw("blocateall", argc, argv, kw, &data)) + DeeObject *item, *key = Dee_None; + size_t start = 0, end = (size_t)-1, result_range[2]; + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, + "o|" UNPuSIZ UNPuSIZ "o:blocateall", + &item, &start, &end, &key)) goto err; - if (!data.sfd_key) { - error = DeeSeq_BFindRange(self, data.sfd_start, data.sfd_end, data.sfd_elem, - NULL, &result_start, &result_end); - } else { - data.sfd_elem = DeeObject_Call(data.sfd_key, 1, &data.sfd_elem); - if unlikely(!data.sfd_elem) - goto err; - error = DeeSeq_BFindRange(self, data.sfd_start, data.sfd_end, data.sfd_elem, - data.sfd_key, &result_start, &result_end); - Dee_Decref(data.sfd_elem); - } - if unlikely(error) + if (!DeeNone_Check(key) + ? new_DeeSeq_BRangeWithKey(self, item, start, end, key, result_range) + : new_DeeSeq_BRange(self, item, start, end, result_range)) goto err; #ifdef CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS - return generic_seq_getrange_index(self, result_start, result_end); + return generic_seq_getrange_index(self, result_range[0], result_range[1]); #else /* CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS */ - return DeeSeq_GetRange(self, result_start, result_end); + return DeeSeq_GetRange(self, result_range[0], result_range[1]); #endif /* !CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS */ err: return NULL; } PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL -seq_binsert(DeeObject *self, size_t argc, - DeeObject *const *argv, DeeObject *kw) { - DREF DeeObject *index, *result; - DeeObject *args[2]; /* elem, key */ - args[1] = Dee_None; - if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_key, "o|o:binsert", &args[0], &args[1])) - goto err; - index = DeeObject_CallAttrString(self, "bposition", 2, args); - if unlikely(!index) +seq_binsert(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { + DeeObject *item; + size_t index, start = 0, end = (size_t)-1; + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end, + "o|" UNPuSIZ UNPuSIZ "o:binsert", + &item, &start, &end)) goto err; - args[1] = args[0]; /* elem */ - args[0] = index; /* index */ - result = DeeObject_CallAttr(self, (DeeObject *)&str_insert, 2, args); - Dee_Decref(args[0]); - return result; + index = new_DeeSeq_BPosition(self, item, start, end); + if unlikely(index == (size_t)Dee_COMPARE_ERR) + goto err; + if unlikely(new_DeeSeq_Insert(self, index, item)) + goto err; + return_none; err: return NULL; } @@ -5163,7 +4967,7 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = { /**/ " return result;\n" /**/ "}" "}"), - TYPE_KWMETHOD(STR_index, &generic_seq_index, + TYPE_KWMETHOD(STR_index, &seq_index, "(item,start:?Dint,end:?Dint,key:?DCallable=!N)->?Dint\n" "#pitem{The element to search for}" "#pkey{A key function for transforming Sequence elements}" @@ -5181,7 +4985,7 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = { /**/ " return result;\n" /**/ "}" "}"), - TYPE_KWMETHOD(STR_rindex, &generic_seq_rindex, + TYPE_KWMETHOD(STR_rindex, &seq_rindex, "(item,start=!0,end=!-1,key:?DCallable=!N)->?Dint\n" "#pitem{The element to search for}" "#pkey{A key function for transforming Sequence elements}" @@ -5840,7 +5644,7 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = { "}"), TYPE_KWMETHOD(STR_removeall, &generic_seq_removeall, "(item,start=!0,end=!-1,max=!-1,key:?DCallable=!N)->?Dint\n" - "#pkey{A key function for transforming Sequence itements}" + "#pkey{A key function for transforming Sequence elements}" "#tSequenceError{@this Sequence is immutable}" "For mutable sequences only: Find all instance of @item and remove " /**/ "them, returning the number of instances found (and consequently removed)\n" @@ -6192,76 +5996,62 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = { "}"), /* Binary search API */ - TYPE_KWMETHOD("bfind", &seq_bfind, - "(elem,key:?DCallable=!N)->?X2?Dint?N\n" - "(elem,start:?Dint,key:?DCallable=!N)->?X2?Dint?N\n" - "(elem,start:?Dint,end:?Dint,key:?DCallable=!N)->?X2?Dint?N\n" - "#pelem{The element to search for}" + TYPE_KWMETHOD("bfind", &generic_seq_bfind, + "(item,start=!0,end=!-1,key:?DCallable=!N)->?X2?Dint?N\n" + "#pitem{The itement to search for}" "#pkey{A key function for transforming Sequence elements}" "#pstart{The start index for a sub-range to search (clamped by ${##this})}" "#pend{The end index for a sub-range to search (clamped by ${##this})}" - "Do a binary search (requiring @this to be sorted via @key) for @elem\n" - "In case multiple elements match @elem, the returned index will be " + "Do a binary search (requiring @this to be sorted via @key) for @item\n" + "In case multiple elements match @item, the returned index will be " /**/ "that for one of them, though it is undefined which one specifically.\n" "When no elements of @this match, ?N is returned."), TYPE_KWMETHOD("bcontains", &seq_bcontains, - "(elem,key:?DCallable=!N)->?Dbool\n" - "(elem,start:?Dint,key:?DCallable=!N)->?Dbool\n" - "(elem,start:?Dint,end:?Dint,key:?DCallable=!N)->?Dbool\n" - "#pelem{The element to search for}" + "(item,start=!0,end=!-1,key:?DCallable=!N)->?Dbool\n" + "#pitem{The itement to search for}" "#pkey{A key function for transforming Sequence elements}" "#pstart{The start index for a sub-range to search (clamped by ${##this})}" "#pend{The end index for a sub-range to search (clamped by ${##this})}" "Wrapper around ?#bfind that simply returns ${this.bfind(...) !is none}"), TYPE_KWMETHOD("bindex", &seq_bindex, - "(elem,key:?DCallable=!N)->?Dint\n" - "(elem,start:?Dint,key:?DCallable=!N)->?Dint\n" - "(elem,start:?Dint,end:?Dint,key:?DCallable=!N)->?Dint\n" - "#pelem{The element to search for}" + "(item,start=!0,end=!-1,key:?DCallable=!N)->?Dint\n" + "#pitem{The itement to search for}" "#pkey{A key function for transforming Sequence elements}" "#pstart{The start index for a sub-range to search (clamped by ${##this})}" "#pend{The end index for a sub-range to search (clamped by ${##this})}" - "#tValueError{The Sequence does not contain an element matching @elem}" + "#tValueError{The Sequence does not contain an itement matching @item}" "Same as ?#bfind, but throw an :ValueError instead of returning ?N."), - TYPE_KWMETHOD("bposition", &seq_bposition, - "(elem,key:?DCallable=!N)->?Dint\n" - "(elem,start:?Dint,key:?DCallable=!N)->?Dint\n" - "(elem,start:?Dint,end:?Dint,key:?DCallable=!N)->?Dint\n" - "#pelem{The element to search for}" + TYPE_KWMETHOD("bposition", &generic_seq_bposition, + "(item,start=!0,end=!-1,key:?DCallable=!N)->?Dint\n" + "#pitem{The itement to search for}" "#pkey{A key function for transforming Sequence elements}" "#pstart{The start index for a sub-range to search (clamped by ${##this})}" "#pend{The end index for a sub-range to search (clamped by ${##this})}" - "Same as ?#bfind, but return (an) index where @elem should be inserted, rather " + "Same as ?#bfind, but return (an) index where @item should be inserted, rather " /**/ "than ?N when @this doesn't contain any matching object"), - TYPE_KWMETHOD("brange", &seq_brange, - "(elem,key:?DCallable=!N)->?T2?Dint?Dint\n" - "(elem,start:?Dint,key:?DCallable=!N)->?T2?Dint?Dint\n" - "(elem,start:?Dint,end:?Dint,key:?DCallable=!N)->?T2?Dint?Dint\n" - "#pelem{The element to search for}" + TYPE_KWMETHOD("brange", &generic_seq_brange, + "(item,start=!0,end=!-1,key:?DCallable=!N)->?T2?Dint?Dint\n" + "#pitem{The itement to search for}" "#pkey{A key function for transforming Sequence elements}" "#pstart{The start index for a sub-range to search (clamped by ${##this})}" "#pend{The end index for a sub-range to search (clamped by ${##this})}" "Similar to ?#bfind, but return a tuple ${[begin,end)} of integers representing " - /**/ "the lower and upper bound of indices for elements from @this matching @elem.\n" + /**/ "the lower and upper bound of indices for elements from @this matching @item.\n" "NOTE: The returned tuple is allowed to be an ASP, meaning that its elements may " /**/ "be calculated lazily, and are prone to change as the result of @this changing."), - TYPE_KWMETHOD("blocate", &seq_blocate, - "(elem,key:?DCallable=!N,defl?)->\n" - "(elem,start:?Dint,key:?DCallable=!N,defl?)->\n" - "(elem,start:?Dint,end:?Dint,key:?DCallable=!N,defl?)->\n" - "#pelem{The element to search for}" + TYPE_KWMETHOD("blocate", &generic_seq_blocate, + "(item,start=!0,end=!-1,key:?DCallable=!N,defl?)->\n" + "#pitem{The itement to search for}" "#pkey{A key function for transforming Sequence elements}" - "#tValueError{The Sequence does not contain an element matching @elem}" - "Same as ?#bfind, but return the matching element, rather than its index"), + "#tValueError{The Sequence does not contain an itement matching @item}" + "Same as ?#bfind, but return the matching itement, rather than its index"), TYPE_KWMETHOD("blocateall", &seq_blocateall, - "(elem,key:?DCallable=!N)->?S?O\n" - "(elem,start:?Dint,key:?DCallable=!N)->?S?O\n" - "(elem,start:?Dint,end:?Dint,key:?DCallable=!N)->?S?O\n" - "#pelem{The element to search for}" + "(item,start=!0,end=!-1,key:?DCallable=!N)->?S?O\n" + "#pitem{The itement to search for}" "#pkey{A key function for transforming Sequence elements}" "#pstart{The start index for a sub-range to search (clamped by ${##this})}" "#pend{The end index for a sub-range to search (clamped by ${##this})}" - "Return the sub-range from @this of elements matching @elem, as returned by ?#brange\n" + "Return the sub-range from @this of elements matching @item, as returned by ?#brange\n" "${" /**/ "function blocateall(args..., **kwds) {\n" /**/ " import Sequence from deemon;\n" @@ -6279,16 +6069,16 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = { /**/ " print l;\n" "}"), TYPE_KWMETHOD("binsert", &seq_binsert, - "(elem,key:?DCallable=!N)\n" + "(item,start=!0,end=!-1)\n" "Helper wrapper for ?#insert and ?#bposition that automatically determines " - /**/ "the index where a given @elem should be inserted to ensure that @this sequence " + /**/ "the index where a given @item should be inserted to ensure that @this sequence " /**/ "remains sorted according to @key. Note that this function makes virtual calls as " /**/ "seen in the following template, meaning it usually doesn't need to be overwritten " /**/ "by sub-classes.\n" "${" - /**/ "function binsert(elem: Object, key: Callable = none) {\n" - /**/ " local index = this.bposition(elem, key);\n" - /**/ " return this.insert(index, elem);\n" + /**/ "function binsert(item: Object, key: Callable = none) {\n" + /**/ " local index = this.bposition(item, key);\n" + /**/ " return this.insert(index, item);\n" /**/ "}" "}"), diff --git a/src/deemon/objects/seq/bsearch-impl.c.inl b/src/deemon/objects/seq/bsearch-impl.c.inl deleted file mode 100644 index 9cde1969a..000000000 --- a/src/deemon/objects/seq/bsearch-impl.c.inl +++ /dev/null @@ -1,234 +0,0 @@ -/* Copyright (c) 2018-2024 Griefer@Work * - * * - * This software is provided 'as-is', without any express or implied * - * warranty. In no event will the authors be held liable for any damages * - * arising from the use of this software. * - * * - * Permission is granted to anyone to use this software for any purpose, * - * including commercial applications, and to alter it and redistribute it * - * freely, subject to the following restrictions: * - * * - * 1. The origin of this software must not be misrepresented; you must not * - * claim that you wrote the original software. If you use this software * - * in a product, an acknowledgement (see the following) in the product * - * documentation is required: * - * Portions Copyright (c) 2018-2024 Griefer@Work * - * 2. Altered source versions must be plainly marked as such, and must not be * - * misrepresented as being the original software. * - * 3. This notice may not be removed or altered from any source distribution. * - */ -#ifdef __INTELLISENSE__ -#include "bsearch.c.inl" -#define DEFINE_LOCAL_bfind_with_nsi_getitem_fast -//#define DEFINE_LOCAL_bfind_with_nsi_getitem -//#define DEFINE_LOCAL_bfind_with_getitem -#endif /* __INTELLISENSE__ */ - -#if (defined(DEFINE_LOCAL_bfind_with_nsi_getitem_fast) + \ - defined(DEFINE_LOCAL_bfind_with_nsi_getitem) + \ - defined(DEFINE_LOCAL_bfind_with_getitem)) != 1 -#error "Must #define exactly one of these macros!" -#endif /* DEFINE_LOCAL_bfind_with_... */ - -DECL_BEGIN - -#ifdef DEFINE_LOCAL_bfind_with_nsi_getitem_fast -#define LOCAL_bfind_with_xxx LOCAL_bfind_with_nsi_getitem_fast -#elif defined(DEFINE_LOCAL_bfind_with_nsi_getitem) -#define LOCAL_bfind_with_xxx LOCAL_bfind_with_nsi_getitem -#else /* defined(DEFINE_LOCAL_bfind_with_getitem) */ -#define LOCAL_bfind_with_xxx LOCAL_bfind_with_getitem -#endif /* ... */ - -PRIVATE WUNUSED LOCAL_return_t DCALL -LOCAL_bfind_with_xxx( -#ifdef DEFINE_LOCAL_bfind_with_getitem - struct type_seq *seq, - size_t seq_length, -#else /* DEFINE_LOCAL_bfind_with_getitem */ - struct type_nsi const *nsi, -#endif /* !DEFINE_LOCAL_bfind_with_getitem */ - DeeObject *self, size_t start, size_t end, - DeeObject *keyed_search_item, DeeObject *key - LOCAL__EXTRA_PARAMS) { -#ifndef DEFINE_LOCAL_bfind_with_getitem - size_t seq_length; - seq_length = (*nsi->nsi_seqlike.nsi_getsize)(self); - if unlikely(seq_length == (size_t)-1) - goto err; -#endif /* !DEFINE_LOCAL_bfind_with_getitem */ - - /* Clamp start/end bounds */ - if (start >= seq_length) - goto notfound; - if (end > seq_length) - end = seq_length; - - /* Do the actual binary search! */ - while (start < end) { - int diff; - DREF DeeObject *seq_elem; - size_t mid = (start + end) / 2; - - /* Load item at `mid' */ -#ifdef DEFINE_LOCAL_bfind_with_nsi_getitem_fast - seq_elem = (*nsi->nsi_seqlike.nsi_getitem_fast)(self, mid); - if unlikely(!seq_elem) - goto notfound; /* Unbound items aren't allowed */ -#elif defined(DEFINE_LOCAL_bfind_with_nsi_getitem) - seq_elem = (*nsi->nsi_seqlike.nsi_getitem)(self, mid); - if unlikely(!seq_elem) - goto err; -#else /* defined(DEFINE_LOCAL_bfind_with_getitem) */ - { - DREF DeeObject *index_ob; - index_ob = DeeInt_NewSize(mid); - if unlikely(!index_ob) - goto err; - seq_elem = (*seq->tp_getitem)(self, index_ob); - Dee_Decref(index_ob); - if unlikely(!seq_elem) - goto err; - } -#endif /* !DEFINE_LOCAL_bfind_with_nsi_getitem_fast */ - - /* Compare `keyed_search_item' and `seq_elem' */ - diff = key ? DeeObject_CompareKey(keyed_search_item, seq_elem, key) - : DeeObject_Compare(keyed_search_item, seq_elem); -#ifndef DEFINE_DeeSeq_BLocate - Dee_Decref(seq_elem); -#endif /* !DEFINE_DeeSeq_BLocate */ - if unlikely(diff == Dee_COMPARE_ERR) - goto err; - - if (diff < 0) { - /* keyed_search_item < self[mid] */ - end = mid; - } else if (diff > 0) { - /* keyed_search_item > self[mid] */ - start = mid + 1; - } else { - /* Match! */ -#ifdef DEFINE_DeeSeq_BFind - return mid; -#elif defined(DEFINE_DeeSeq_BFindRange) - size_t result_start = mid; - size_t result_end = mid + 1; - - /* Widen the result range's lower bound */ - while (result_start > start) { - mid = (result_start + start) / 2; -#ifdef DEFINE_LOCAL_bfind_with_nsi_getitem_fast - seq_elem = (*nsi->nsi_seqlike.nsi_getitem_fast)(self, mid); - if unlikely(!seq_elem) - goto notfound; /* Unbound items aren't allowed */ -#elif defined(DEFINE_LOCAL_bfind_with_nsi_getitem) - seq_elem = (*nsi->nsi_seqlike.nsi_getitem)(self, mid); - if unlikely(!seq_elem) - goto err; -#else /* defined(DEFINE_LOCAL_bfind_with_getitem) */ - { - DREF DeeObject *index_ob; - index_ob = DeeInt_NewSize(mid); - if unlikely(!index_ob) - goto err; - seq_elem = (*seq->tp_getitem)(self, index_ob); - Dee_Decref(index_ob); - if unlikely(!seq_elem) - goto err; - } -#endif /* !DEFINE_LOCAL_bfind_with_nsi_getitem_fast */ - diff = DeeObject_TryCmpKeyEqAsBool(keyed_search_item, seq_elem, key); - Dee_Decref(seq_elem); - if (diff > 0) { - /* Still part of returned range! */ - result_start = mid; - } else { - if unlikely(diff < 0) - goto err; - /* No longer part of returned range! */ - start = mid + 1; - } - } - - /* Widen the result range's upper bound */ - while (result_end < end) { - mid = (result_end + end) / 2; -#ifdef DEFINE_LOCAL_bfind_with_nsi_getitem_fast - seq_elem = (*nsi->nsi_seqlike.nsi_getitem_fast)(self, mid); - if unlikely(!seq_elem) - goto notfound; /* Unbound items aren't allowed */ -#elif defined(DEFINE_LOCAL_bfind_with_nsi_getitem) - seq_elem = (*nsi->nsi_seqlike.nsi_getitem)(self, mid); - if unlikely(!seq_elem) - goto err; -#else /* defined(DEFINE_LOCAL_bfind_with_getitem) */ - { - DREF DeeObject *index_ob; - index_ob = DeeInt_NewSize(mid); - if unlikely(!index_ob) - goto err; - seq_elem = (*seq->tp_getitem)(self, index_ob); - Dee_Decref(index_ob); - if unlikely(!seq_elem) - goto err; - } -#endif /* !DEFINE_LOCAL_bfind_with_nsi_getitem_fast */ - diff = DeeObject_TryCmpKeyEqAsBool(keyed_search_item, seq_elem, key); - Dee_Decref(seq_elem); - if (diff > 0) { - /* Still part of returned range! */ - result_end = mid + 1; - } else { - if unlikely(diff < 0) - goto err; - /* No longer part of returned range! */ - end = mid; - } - } - - /* Write-back the result indices */ - *p_startindex = result_start; - *p_endindex = result_end; - return 0; -#elif defined(DEFINE_DeeSeq_BFindPosition) - if unlikely(mid == (size_t)-1) - err_integer_overflow_i(sizeof(size_t) * CHAR_BIT, true); - return mid; -#else /* defined(DEFINE_DeeSeq_BLocate) */ - return seq_elem; -#endif /* ... */ - } - -#ifdef DEFINE_DeeSeq_BLocate - Dee_Decref(seq_elem); -#endif /* !DEFINE_DeeSeq_BLocate */ - } -notfound: -#ifdef DEFINE_DeeSeq_BFind - return (size_t)-1; -#elif defined(DEFINE_DeeSeq_BFindRange) - *p_startindex = start; - *p_endindex = start; - return 0; -#elif defined(DEFINE_DeeSeq_BFindPosition) - if unlikely(start == (size_t)-1) - err_integer_overflow_i(sizeof(size_t) * CHAR_BIT, true); - return start; -#else /* defined(DEFINE_DeeSeq_BLocate) */ - if (defl) - return_reference_(defl); - err_item_not_found(self, keyed_search_item); - /* FALLTHRU to `err' */ -#endif /* ... */ -err: - return LOCAL_ERROR_RESULT; -} - -#undef LOCAL_bfind_with_xxx - -DECL_END - -#undef DEFINE_LOCAL_bfind_with_nsi_getitem_fast -#undef DEFINE_LOCAL_bfind_with_nsi_getitem -#undef DEFINE_LOCAL_bfind_with_getitem diff --git a/src/deemon/objects/seq/bsearch.c b/src/deemon/objects/seq/bsearch.c deleted file mode 100644 index 53d662a2a..000000000 --- a/src/deemon/objects/seq/bsearch.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2018-2024 Griefer@Work * - * * - * This software is provided 'as-is', without any express or implied * - * warranty. In no event will the authors be held liable for any damages * - * arising from the use of this software. * - * * - * Permission is granted to anyone to use this software for any purpose, * - * including commercial applications, and to alter it and redistribute it * - * freely, subject to the following restrictions: * - * * - * 1. The origin of this software must not be misrepresented; you must not * - * claim that you wrote the original software. If you use this software * - * in a product, an acknowledgement (see the following) in the product * - * documentation is required: * - * Portions Copyright (c) 2018-2024 Griefer@Work * - * 2. Altered source versions must be plainly marked as such, and must not be * - * misrepresented as being the original software. * - * 3. This notice may not be removed or altered from any source distribution. * - */ -#ifndef GUARD_DEEMON_OBJECTS_SEQ_BSEARCH_C -#define GUARD_DEEMON_OBJECTS_SEQ_BSEARCH_C 1 - -#include -#include -#include -#include - -#ifndef CHAR_BIT -#include -#define CHAR_BIT __CHAR_BIT__ -#endif /* !CHAR_BIT */ - -DECL_BEGIN - -PRIVATE ATTR_COLD NONNULL((1)) int DCALL -err_no_generic_sequence(DeeObject *__restrict self) { - return DeeError_Throwf(&DeeError_NotImplemented, - "Neither `%k.__getitem__' and `%k.__size__', nor `%k.__iter__' are implemented", - Dee_TYPE(self), Dee_TYPE(self), Dee_TYPE(self)); -} - - -DECL_END - -#ifndef __INTELLISENSE__ -#define DEFINE_DeeSeq_BFind -#include "bsearch.c.inl" -#define DEFINE_DeeSeq_BFindRange -#include "bsearch.c.inl" -#define DEFINE_DeeSeq_BFindPosition -#include "bsearch.c.inl" -#define DEFINE_DeeSeq_BLocate -#include "bsearch.c.inl" -#endif /* !__INTELLISENSE__ */ - -#endif /* !GUARD_DEEMON_OBJECTS_SEQ_BSEARCH_C */ diff --git a/src/deemon/objects/seq/bsearch.c.inl b/src/deemon/objects/seq/bsearch.c.inl deleted file mode 100644 index f85312c55..000000000 --- a/src/deemon/objects/seq/bsearch.c.inl +++ /dev/null @@ -1,226 +0,0 @@ -/* Copyright (c) 2018-2024 Griefer@Work * - * * - * This software is provided 'as-is', without any express or implied * - * warranty. In no event will the authors be held liable for any damages * - * arising from the use of this software. * - * * - * Permission is granted to anyone to use this software for any purpose, * - * including commercial applications, and to alter it and redistribute it * - * freely, subject to the following restrictions: * - * * - * 1. The origin of this software must not be misrepresented; you must not * - * claim that you wrote the original software. If you use this software * - * in a product, an acknowledgement (see the following) in the product * - * documentation is required: * - * Portions Copyright (c) 2018-2024 Griefer@Work * - * 2. Altered source versions must be plainly marked as such, and must not be * - * misrepresented as being the original software. * - * 3. This notice may not be removed or altered from any source distribution. * - */ -#ifdef __INTELLISENSE__ -#include "bsearch.c" -//#define DEFINE_DeeSeq_BFind -#define DEFINE_DeeSeq_BFindRange -//#define DEFINE_DeeSeq_BFindPosition -//#define DEFINE_DeeSeq_BLocate -#endif /* __INTELLISENSE__ */ - -#include -#include -#include -#include - -#include "../../runtime/runtime_error.h" -#include "../seq_functions.h" - -#if (defined(DEFINE_DeeSeq_BFind) + \ - defined(DEFINE_DeeSeq_BFindRange) + \ - defined(DEFINE_DeeSeq_BFindPosition) + \ - defined(DEFINE_DeeSeq_BLocate)) != 1 -#error "Must #define exactly one of these macros!" -#endif /* DEFINE_DeeSeq_... */ - -DECL_BEGIN - -#ifdef DEFINE_DeeSeq_BFind -#define LOCAL_bfind_with_nsi_getitem_fast bfind_with_nsi_getitem_fast -#define LOCAL_bfind_with_nsi_getitem bfind_with_nsi_getitem -#define LOCAL_bfind_with_getitem bfind_with_getitem -#define LOCAL_DeeSeq_BFind DeeSeq_BFind -#define LOCAL_return_t size_t -#define LOCAL__EXTRA_PARAMS /* nothing */ -#define LOCAL__EXTRA_ARGS /* nothing */ -#define LOCAL_ERROR_RESULT ((size_t)-2) -#elif defined(DEFINE_DeeSeq_BFindRange) -#define LOCAL_bfind_with_nsi_getitem_fast bfindrange_with_nsi_getitem_fast -#define LOCAL_bfind_with_nsi_getitem bfindrange_with_nsi_getitem -#define LOCAL_bfind_with_getitem bfindrange_with_getitem -#define LOCAL_DeeSeq_BFind DeeSeq_BFindRange -#define LOCAL_return_t int -#define LOCAL__EXTRA_PARAMS , size_t *__restrict p_startindex, size_t *__restrict p_endindex -#define LOCAL__EXTRA_ARGS , p_startindex, p_endindex -#define LOCAL_ERROR_RESULT (-1) -#elif defined(DEFINE_DeeSeq_BFindPosition) -#define LOCAL_bfind_with_nsi_getitem_fast bfindposition_with_nsi_getitem_fast -#define LOCAL_bfind_with_nsi_getitem bfindposition_with_nsi_getitem -#define LOCAL_bfind_with_getitem bfindposition_with_getitem -#define LOCAL_DeeSeq_BFind DeeSeq_BFindPosition -#define LOCAL_return_t size_t -#define LOCAL__EXTRA_PARAMS /* nothing */ -#define LOCAL__EXTRA_ARGS /* nothing */ -#define LOCAL_ERROR_RESULT ((size_t)-1) -#else /* defined(DEFINE_DeeSeq_BLocate) */ -#define LOCAL_bfind_with_nsi_getitem_fast blocate_with_nsi_getitem_fast -#define LOCAL_bfind_with_nsi_getitem blocate_with_nsi_getitem -#define LOCAL_bfind_with_getitem blocate_with_getitem -#define LOCAL_DeeSeq_BFind DeeSeq_BLocate -#define LOCAL_return_t DREF DeeObject * -#define LOCAL__EXTRA_PARAMS , DeeObject *defl -#define LOCAL__EXTRA_ARGS , defl -#define LOCAL_ERROR_RESULT NULL -#endif /* ... */ - -#ifdef __INTELLISENSE__ -PRIVATE WUNUSED LOCAL_return_t DCALL -LOCAL_bfind_with_nsi_getitem_fast(struct type_nsi const *nsi, - DeeObject *self, size_t start, size_t end, - DeeObject *keyed_search_item, DeeObject *key - LOCAL__EXTRA_PARAMS); -PRIVATE WUNUSED LOCAL_return_t DCALL -LOCAL_bfind_with_nsi_getitem(struct type_nsi const *nsi, - DeeObject *self, size_t start, size_t end, - DeeObject *keyed_search_item, DeeObject *key - LOCAL__EXTRA_PARAMS); -PRIVATE WUNUSED LOCAL_return_t DCALL -LOCAL_bfind_with_getitem(struct type_seq *seq, size_t seq_length, - DeeObject *self, size_t start, size_t end, - DeeObject *keyed_search_item, DeeObject *key - LOCAL__EXTRA_PARAMS); -#else /* __INTELLISENSE__ */ -DECL_END - -#define DEFINE_LOCAL_bfind_with_nsi_getitem_fast -#include "bsearch-impl.c.inl" -#define DEFINE_LOCAL_bfind_with_nsi_getitem -#include "bsearch-impl.c.inl" -#define DEFINE_LOCAL_bfind_with_getitem -#include "bsearch-impl.c.inl" - -DECL_BEGIN -#endif /* !__INTELLISENSE__ */ - - - -/* Binary search for `keyed_search_item' in `self' */ -INTERN WUNUSED LOCAL_return_t DCALL -LOCAL_DeeSeq_BFind(DeeObject *self, size_t start, size_t end, - DeeObject *keyed_search_item, DeeObject *key - LOCAL__EXTRA_PARAMS) { - DeeTypeObject *tp_self; - DeeTypeMRO mro; - ASSERT_OBJECT(self); - if unlikely(start >= end) - goto notfound; - tp_self = Dee_TYPE(self); - DeeTypeMRO_Init(&mro, tp_self); - while (tp_self != &DeeSeq_Type) { - struct type_seq *seq = tp_self->tp_seq; - if (seq) { - size_t seq_length; - struct type_nsi const *nsi = seq->tp_nsi; - if (nsi && nsi->nsi_class == TYPE_SEQX_CLASS_SEQ && - is_noninherited_nsi(tp_self, seq, nsi)) { - if (nsi->nsi_seqlike.nsi_getitem_fast) { - return LOCAL_bfind_with_nsi_getitem_fast(nsi, self, start, end, - keyed_search_item, key - LOCAL__EXTRA_ARGS); - } - if (nsi->nsi_seqlike.nsi_getitem) { - return LOCAL_bfind_with_nsi_getitem(nsi, self, start, end, - keyed_search_item, key - LOCAL__EXTRA_ARGS); - } - if (has_noninherited_getitem(tp_self, seq)) { - seq_length = (*nsi->nsi_seqlike.nsi_getsize)(self); - if unlikely(seq_length == (size_t)-1) - goto err; -do_lookup_tpget: - return LOCAL_bfind_with_getitem(seq, seq_length, self, start, end, - keyed_search_item, key - LOCAL__EXTRA_ARGS); - } - } - if (has_noninherited_getitem(tp_self, seq) && - has_noninherited_size(tp_self, seq)) { - DREF DeeObject *size_ob; - int error; - size_ob = (*seq->tp_sizeob)(self); - if unlikely(!size_ob) - goto err; - error = DeeObject_AsSize(size_ob, &seq_length); - Dee_Decref(size_ob); - if unlikely(error) - goto err; - goto do_lookup_tpget; - } - if (seq->tp_iter) { - /* Use iterators to convert to a tuple, then do the lookup on said tuple. */ - LOCAL_return_t result; - DREF DeeObject *tuple; - DREF DeeObject *iterator; - if unlikely((iterator = (*seq->tp_iter)(self)) == NULL) - goto err; - tuple = DeeTuple_FromIterator(iterator); - Dee_Decref(iterator); - if unlikely(!tuple) - goto err; - result = LOCAL_bfind_with_nsi_getitem_fast(DeeTuple_Type.tp_seq->tp_nsi, tuple, - start, end, keyed_search_item, key - LOCAL__EXTRA_ARGS); - Dee_Decref(tuple); - return result; - } - } - tp_self = DeeTypeMRO_Next(&mro, tp_self); - if (tp_self == NULL) - break; - } - err_no_generic_sequence(self); -err: - return LOCAL_ERROR_RESULT; -notfound: -#ifdef DEFINE_DeeSeq_BFind - return (size_t)-1; -#elif defined(DEFINE_DeeSeq_BFindRange) - *p_startindex = start; - *p_endindex = start; - return 0; -#elif defined(DEFINE_DeeSeq_BFindPosition) - if unlikely(start == (size_t)-1) - err_integer_overflow_i(sizeof(size_t) * CHAR_BIT, true); - return start; -#else /* defined(DEFINE_DeeSeq_BLocate) */ - if (defl) - return_reference_(defl); - err_item_not_found(self, keyed_search_item); - return NULL; -#endif /* ... */ -} - -DECL_END - -#ifndef __INTELLISENSE__ -#undef LOCAL_bfind_with_nsi_getitem_fast -#undef LOCAL_bfind_with_nsi_getitem -#undef LOCAL_bfind_with_getitem -#undef LOCAL_DeeSeq_BFind -#undef LOCAL_return_t -#undef LOCAL__EXTRA_PARAMS -#undef LOCAL__EXTRA_ARGS -#undef LOCAL_ERROR_RESULT - -#undef DEFINE_DeeSeq_BFind -#undef DEFINE_DeeSeq_BFindRange -#undef DEFINE_DeeSeq_BFindPosition -#undef DEFINE_DeeSeq_BLocate -#endif /* !__INTELLISENSE__ */ diff --git a/src/deemon/objects/seq/bsearch.h b/src/deemon/objects/seq/bsearch.h deleted file mode 100644 index 61724ce1b..000000000 --- a/src/deemon/objects/seq/bsearch.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (c) 2018-2024 Griefer@Work * - * * - * This software is provided 'as-is', without any express or implied * - * warranty. In no event will the authors be held liable for any damages * - * arising from the use of this software. * - * * - * Permission is granted to anyone to use this software for any purpose, * - * including commercial applications, and to alter it and redistribute it * - * freely, subject to the following restrictions: * - * * - * 1. The origin of this software must not be misrepresented; you must not * - * claim that you wrote the original software. If you use this software * - * in a product, an acknowledgement (see the following) in the product * - * documentation is required: * - * Portions Copyright (c) 2018-2024 Griefer@Work * - * 2. Altered source versions must be plainly marked as such, and must not be * - * misrepresented as being the original software. * - * 3. This notice may not be removed or altered from any source distribution. * - */ -#ifndef GUARD_DEEMON_OBJECTS_SEQ_BSEARCH_H -#define GUARD_DEEMON_OBJECTS_SEQ_BSEARCH_H 1 - -#include -#include - -DECL_BEGIN - -/* Binary search for `keyed_search_item' - * In case multiple elements match `keyed_search_item', the returned index - * will be that for one of them, though it is undefined which one specifically. - * @return: (size_t)-1: Not found. - * @return: (size_t)-2: Error. */ -INTDEF WUNUSED NONNULL((1, 4)) size_t DCALL -DeeSeq_BFind(DeeObject *self, size_t start, size_t end, - DeeObject *keyed_search_item, DeeObject *key); - -/* Find the index-range of all items, such that: - * >> for (elem: self[*p_startindex:*p_endindex]) - * >> assert keyed_search_item == key(elem); - * @return: 0: Success - * @return: -1: Error. */ -INTDEF WUNUSED NONNULL((1, 4, 6, 7)) int DCALL -DeeSeq_BFindRange(DeeObject *self, size_t start, size_t end, - DeeObject *keyed_search_item, DeeObject *key, - size_t *__restrict p_startindex, - size_t *__restrict p_endindex); - -/* Same as `DeeSeq_BFind()', but return index where `keyed_search_item' - * should go in case no matching item already exists in `self' - * @return: (size_t)-1: Error. */ -INTDEF WUNUSED NONNULL((1, 4)) size_t DCALL -DeeSeq_BFindPosition(DeeObject *self, size_t start, size_t end, - DeeObject *keyed_search_item, DeeObject *key); - -/* Returns `self[DeeSeq_BFind(self, keyed_search_item, key)]' - * In case multiple elements match `keyed_search_item', the - * returned item will be one of them, though which one is - * undefined. - * @return: NULL: Error, or not found (and `defl' is NULL). */ -INTDEF WUNUSED NONNULL((1, 4)) DREF DeeObject *DCALL -DeeSeq_BLocate(DeeObject *self, size_t start, size_t end, - DeeObject *keyed_search_item, DeeObject *key, - DeeObject *defl); - -DECL_END - -#endif /* !GUARD_DEEMON_OBJECTS_SEQ_BSEARCH_H */ diff --git a/src/deemon/objects/seq/default-api-methods-attrproxy-impl.c.inl b/src/deemon/objects/seq/default-api-methods-attrproxy-impl.c.inl index 727041a68..bc7ea7fd2 100644 --- a/src/deemon/objects/seq/default-api-methods-attrproxy-impl.c.inl +++ b/src/deemon/objects/seq/default-api-methods-attrproxy-impl.c.inl @@ -35,126 +35,55 @@ DECL_BEGIN #endif /* DEFINE_DeeSeq_Default... */ #ifdef DEFINE_DeeSeq_DefaultFooWithCallAttrFoo -#define LOCAL_DeeSeq_DefaultFindWithCallAttrFind DeeSeq_DefaultFindWithCallAttrFind -#define LOCAL_DeeSeq_DefaultFindWithKeyWithCallAttrFind DeeSeq_DefaultFindWithKeyWithCallAttrFind -#define LOCAL_DeeSeq_DefaultRFindWithCallAttrRFind DeeSeq_DefaultRFindWithCallAttrRFind -#define LOCAL_DeeSeq_DefaultRFindWithKeyWithCallAttrRFind DeeSeq_DefaultRFindWithKeyWithCallAttrRFind -#define LOCAL_DeeSeq_DefaultEraseWithCallAttrErase DeeSeq_DefaultEraseWithCallAttrErase -#define LOCAL_DeeSeq_DefaultInsertWithCallAttrInsert DeeSeq_DefaultInsertWithCallAttrInsert -#define LOCAL_DeeSeq_DefaultInsertAllWithCallAttrInsertAll DeeSeq_DefaultInsertAllWithCallAttrInsertAll -#define LOCAL_DeeSeq_DefaultPushFrontWithCallAttrPushFront DeeSeq_DefaultPushFrontWithCallAttrPushFront -#define LOCAL_DeeSeq_DefaultAppendWithCallAttrAppend DeeSeq_DefaultAppendWithCallAttrAppend -#define LOCAL_DeeSeq_DefaultAppendWithCallAttrPushBack DeeSeq_DefaultAppendWithCallAttrPushBack -#define LOCAL_DeeSeq_DefaultExtendWithCallAttrExtend DeeSeq_DefaultExtendWithCallAttrExtend -#define LOCAL_DeeSeq_DefaultXchItemIndexWithCallAttrXchItem DeeSeq_DefaultXchItemIndexWithCallAttrXchItem -#define LOCAL_DeeSeq_DefaultClearWithCallAttrClear DeeSeq_DefaultClearWithCallAttrClear -#define LOCAL_DeeSeq_DefaultPopWithCallAttrPop DeeSeq_DefaultPopWithCallAttrPop -#define LOCAL_DeeSeq_DefaultRemoveWithCallAttrRemove DeeSeq_DefaultRemoveWithCallAttrRemove -#define LOCAL_DeeSeq_DefaultRemoveWithKeyWithCallAttrRemove DeeSeq_DefaultRemoveWithKeyWithCallAttrRemove -#define LOCAL_DeeSeq_DefaultRRemoveWithCallAttrRRemove DeeSeq_DefaultRRemoveWithCallAttrRRemove -#define LOCAL_DeeSeq_DefaultRRemoveWithKeyWithCallAttrRRemove DeeSeq_DefaultRRemoveWithKeyWithCallAttrRRemove -#define LOCAL_DeeSeq_DefaultRemoveAllWithCallAttrRemoveAll DeeSeq_DefaultRemoveAllWithCallAttrRemoveAll -#define LOCAL_DeeSeq_DefaultRemoveAllWithKeyWithCallAttrRemoveAll DeeSeq_DefaultRemoveAllWithKeyWithCallAttrRemoveAll -#define LOCAL_DeeSeq_DefaultRemoveIfWithCallAttrRemoveIf DeeSeq_DefaultRemoveIfWithCallAttrRemoveIf -#define LOCAL_DeeSeq_DefaultResizeWithCallAttrResize DeeSeq_DefaultResizeWithCallAttrResize -#define LOCAL_DeeSeq_DefaultFillWithCallAttrFill DeeSeq_DefaultFillWithCallAttrFill -#define LOCAL_DeeSeq_DefaultReverseWithCallAttrReverse DeeSeq_DefaultReverseWithCallAttrReverse -#define LOCAL_DeeSeq_DefaultReversedWithCallAttrReversed DeeSeq_DefaultReversedWithCallAttrReversed -#define LOCAL_DeeSeq_DefaultSortWithCallAttrSort DeeSeq_DefaultSortWithCallAttrSort -#define LOCAL_DeeSeq_DefaultSortWithKeyWithCallAttrSort DeeSeq_DefaultSortWithKeyWithCallAttrSort -#define LOCAL_DeeSeq_DefaultSortedWithCallAttrSorted DeeSeq_DefaultSortedWithCallAttrSorted -#define LOCAL_DeeSeq_DefaultSortedWithKeyWithCallAttrSorted DeeSeq_DefaultSortedWithKeyWithCallAttrSorted +#define LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Foo, Bar) PP_CAT4(DeeSeq_Default, Foo, WithCallAttr, Bar) #elif defined(DEFINE_DeeSeq_DefaultFooWithCallFooDataFunction) -#define LOCAL_DeeSeq_DefaultFindWithCallAttrFind DeeSeq_DefaultFindWithCallFindDataFunction -#define LOCAL_DeeSeq_DefaultFindWithKeyWithCallAttrFind DeeSeq_DefaultFindWithKeyWithCallFindDataFunction -#define LOCAL_DeeSeq_DefaultRFindWithCallAttrRFind DeeSeq_DefaultRFindWithCallRFindDataFunction -#define LOCAL_DeeSeq_DefaultRFindWithKeyWithCallAttrRFind DeeSeq_DefaultRFindWithKeyWithCallRFindDataFunction -#define LOCAL_DeeSeq_DefaultEraseWithCallAttrErase DeeSeq_DefaultEraseWithCallEraseDataFunction -#define LOCAL_DeeSeq_DefaultInsertWithCallAttrInsert DeeSeq_DefaultInsertWithCallInsertDataFunction -#define LOCAL_DeeSeq_DefaultInsertAllWithCallAttrInsertAll DeeSeq_DefaultInsertAllWithCallInsertAllDataFunction -#define LOCAL_DeeSeq_DefaultPushFrontWithCallAttrPushFront DeeSeq_DefaultPushFrontWithCallPushFrontDataFunction -#define LOCAL_DeeSeq_DefaultAppendWithCallAttrAppend DeeSeq_DefaultAppendWithCallAppendDataFunction -#define LOCAL_DeeSeq_DefaultExtendWithCallAttrExtend DeeSeq_DefaultExtendWithCallExtendDataFunction -#define LOCAL_DeeSeq_DefaultXchItemIndexWithCallAttrXchItem DeeSeq_DefaultXchItemIndexWithCallXchItemIndexDataFunction -#define LOCAL_DeeSeq_DefaultClearWithCallAttrClear DeeSeq_DefaultClearWithCallClearDataFunction -#define LOCAL_DeeSeq_DefaultPopWithCallAttrPop DeeSeq_DefaultPopWithCallPopDataFunction -#define LOCAL_DeeSeq_DefaultRemoveWithCallAttrRemove DeeSeq_DefaultRemoveWithCallRemoveDataFunction -#define LOCAL_DeeSeq_DefaultRemoveWithKeyWithCallAttrRemove DeeSeq_DefaultRemoveWithKeyWithCallRemoveDataFunction -#define LOCAL_DeeSeq_DefaultRRemoveWithCallAttrRRemove DeeSeq_DefaultRRemoveWithCallRRemoveDataFunction -#define LOCAL_DeeSeq_DefaultRRemoveWithKeyWithCallAttrRRemove DeeSeq_DefaultRRemoveWithKeyWithCallRRemoveDataFunction -#define LOCAL_DeeSeq_DefaultRemoveAllWithCallAttrRemoveAll DeeSeq_DefaultRemoveAllWithCallRemoveAllDataFunction -#define LOCAL_DeeSeq_DefaultRemoveAllWithKeyWithCallAttrRemoveAll DeeSeq_DefaultRemoveAllWithKeyWithCallRemoveAllDataFunction -#define LOCAL_DeeSeq_DefaultRemoveIfWithCallAttrRemoveIf DeeSeq_DefaultRemoveIfWithCallRemoveIfDataFunction -#define LOCAL_DeeSeq_DefaultResizeWithCallAttrResize DeeSeq_DefaultResizeWithCallResizeDataFunction -#define LOCAL_DeeSeq_DefaultFillWithCallAttrFill DeeSeq_DefaultFillWithCallFillDataFunction -#define LOCAL_DeeSeq_DefaultReverseWithCallAttrReverse DeeSeq_DefaultReverseWithCallReverseDataFunction -#define LOCAL_DeeSeq_DefaultReversedWithCallAttrReversed DeeSeq_DefaultReversedWithCallReversedDataFunction -#define LOCAL_DeeSeq_DefaultSortWithCallAttrSort DeeSeq_DefaultSortWithCallSortDataFunction -#define LOCAL_DeeSeq_DefaultSortWithKeyWithCallAttrSort DeeSeq_DefaultSortWithKeyWithCallSortDataFunction -#define LOCAL_DeeSeq_DefaultSortedWithCallAttrSorted DeeSeq_DefaultSortedWithCallSortedDataFunction -#define LOCAL_DeeSeq_DefaultSortedWithKeyWithCallAttrSorted DeeSeq_DefaultSortedWithKeyWithCallSortedDataFunction +#define LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Foo, Bar) PP_CAT5(DeeSeq_Default, Foo, WithCall, Bar, DataFunction) #elif defined(DEFINE_DeeSeq_DefaultFooWithCallFooDataMethod) -#define LOCAL_DeeSeq_DefaultFindWithCallAttrFind DeeSeq_DefaultFindWithCallFindDataMethod -#define LOCAL_DeeSeq_DefaultFindWithKeyWithCallAttrFind DeeSeq_DefaultFindWithKeyWithCallFindDataMethod -#define LOCAL_DeeSeq_DefaultRFindWithCallAttrRFind DeeSeq_DefaultRFindWithCallRFindDataMethod -#define LOCAL_DeeSeq_DefaultRFindWithKeyWithCallAttrRFind DeeSeq_DefaultRFindWithKeyWithCallRFindDataMethod -#define LOCAL_DeeSeq_DefaultEraseWithCallAttrErase DeeSeq_DefaultEraseWithCallEraseDataMethod -#define LOCAL_DeeSeq_DefaultInsertWithCallAttrInsert DeeSeq_DefaultInsertWithCallInsertDataMethod -#define LOCAL_DeeSeq_DefaultInsertAllWithCallAttrInsertAll DeeSeq_DefaultInsertAllWithCallInsertAllDataMethod -#define LOCAL_DeeSeq_DefaultPushFrontWithCallAttrPushFront DeeSeq_DefaultPushFrontWithCallPushFrontDataMethod -#define LOCAL_DeeSeq_DefaultAppendWithCallAttrAppend DeeSeq_DefaultAppendWithCallAppendDataMethod -#define LOCAL_DeeSeq_DefaultExtendWithCallAttrExtend DeeSeq_DefaultExtendWithCallExtendDataMethod -#define LOCAL_DeeSeq_DefaultXchItemIndexWithCallAttrXchItem DeeSeq_DefaultXchItemIndexWithCallXchItemIndexDataMethod -#define LOCAL_DeeSeq_DefaultClearWithCallAttrClear DeeSeq_DefaultClearWithCallClearDataMethod -#define LOCAL_DeeSeq_DefaultPopWithCallAttrPop DeeSeq_DefaultPopWithCallPopDataMethod -#define LOCAL_DeeSeq_DefaultRemoveWithCallAttrRemove DeeSeq_DefaultRemoveWithCallRemoveDataMethod -#define LOCAL_DeeSeq_DefaultRemoveWithKeyWithCallAttrRemove DeeSeq_DefaultRemoveWithKeyWithCallRemoveDataMethod -#define LOCAL_DeeSeq_DefaultRRemoveWithCallAttrRRemove DeeSeq_DefaultRRemoveWithCallRRemoveDataMethod -#define LOCAL_DeeSeq_DefaultRRemoveWithKeyWithCallAttrRRemove DeeSeq_DefaultRRemoveWithKeyWithCallRRemoveDataMethod -#define LOCAL_DeeSeq_DefaultRemoveAllWithCallAttrRemoveAll DeeSeq_DefaultRemoveAllWithCallRemoveAllDataMethod -#define LOCAL_DeeSeq_DefaultRemoveAllWithKeyWithCallAttrRemoveAll DeeSeq_DefaultRemoveAllWithKeyWithCallRemoveAllDataMethod -#define LOCAL_DeeSeq_DefaultRemoveIfWithCallAttrRemoveIf DeeSeq_DefaultRemoveIfWithCallRemoveIfDataMethod -#define LOCAL_DeeSeq_DefaultResizeWithCallAttrResize DeeSeq_DefaultResizeWithCallResizeDataMethod -#define LOCAL_DeeSeq_DefaultFillWithCallAttrFill DeeSeq_DefaultFillWithCallFillDataMethod -#define LOCAL_DeeSeq_DefaultReverseWithCallAttrReverse DeeSeq_DefaultReverseWithCallReverseDataMethod -#define LOCAL_DeeSeq_DefaultReversedWithCallAttrReversed DeeSeq_DefaultReversedWithCallReversedDataMethod -#define LOCAL_DeeSeq_DefaultSortWithCallAttrSort DeeSeq_DefaultSortWithCallSortDataMethod -#define LOCAL_DeeSeq_DefaultSortWithKeyWithCallAttrSort DeeSeq_DefaultSortWithKeyWithCallSortDataMethod -#define LOCAL_DeeSeq_DefaultSortedWithCallAttrSorted DeeSeq_DefaultSortedWithCallSortedDataMethod -#define LOCAL_DeeSeq_DefaultSortedWithKeyWithCallAttrSorted DeeSeq_DefaultSortedWithKeyWithCallSortedDataMethod +#define LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Foo, Bar) PP_CAT5(DeeSeq_Default, Foo, WithCall, Bar, DataMethod) #elif defined(DEFINE_DeeSeq_DefaultFooWithCallFooDataKwMethod) -#define LOCAL_DeeSeq_DefaultFindWithCallAttrFind DeeSeq_DefaultFindWithCallFindDataKwMethod -#define LOCAL_DeeSeq_DefaultFindWithKeyWithCallAttrFind DeeSeq_DefaultFindWithKeyWithCallFindDataKwMethod -#define LOCAL_DeeSeq_DefaultRFindWithCallAttrRFind DeeSeq_DefaultRFindWithCallRFindDataKwMethod -#define LOCAL_DeeSeq_DefaultRFindWithKeyWithCallAttrRFind DeeSeq_DefaultRFindWithKeyWithCallRFindDataKwMethod -#define LOCAL_DeeSeq_DefaultEraseWithCallAttrErase DeeSeq_DefaultEraseWithCallEraseDataKwMethod -#define LOCAL_DeeSeq_DefaultInsertWithCallAttrInsert DeeSeq_DefaultInsertWithCallInsertDataKwMethod -#define LOCAL_DeeSeq_DefaultInsertAllWithCallAttrInsertAll DeeSeq_DefaultInsertAllWithCallInsertAllDataKwMethod -#define LOCAL_DeeSeq_DefaultPushFrontWithCallAttrPushFront DeeSeq_DefaultPushFrontWithCallPushFrontDataKwMethod -#define LOCAL_DeeSeq_DefaultAppendWithCallAttrAppend DeeSeq_DefaultAppendWithCallAppendDataKwMethod -#define LOCAL_DeeSeq_DefaultExtendWithCallAttrExtend DeeSeq_DefaultExtendWithCallExtendDataKwMethod -#define LOCAL_DeeSeq_DefaultXchItemIndexWithCallAttrXchItem DeeSeq_DefaultXchItemIndexWithCallXchItemIndexDataKwMethod -#define LOCAL_DeeSeq_DefaultClearWithCallAttrClear DeeSeq_DefaultClearWithCallClearDataKwMethod -#define LOCAL_DeeSeq_DefaultPopWithCallAttrPop DeeSeq_DefaultPopWithCallPopDataKwMethod -#define LOCAL_DeeSeq_DefaultRemoveWithCallAttrRemove DeeSeq_DefaultRemoveWithCallRemoveDataKwMethod -#define LOCAL_DeeSeq_DefaultRemoveWithKeyWithCallAttrRemove DeeSeq_DefaultRemoveWithKeyWithCallRemoveDataKwMethod -#define LOCAL_DeeSeq_DefaultRRemoveWithCallAttrRRemove DeeSeq_DefaultRRemoveWithCallRRemoveDataKwMethod -#define LOCAL_DeeSeq_DefaultRRemoveWithKeyWithCallAttrRRemove DeeSeq_DefaultRRemoveWithKeyWithCallRRemoveDataKwMethod -#define LOCAL_DeeSeq_DefaultRemoveAllWithCallAttrRemoveAll DeeSeq_DefaultRemoveAllWithCallRemoveAllDataKwMethod -#define LOCAL_DeeSeq_DefaultRemoveAllWithKeyWithCallAttrRemoveAll DeeSeq_DefaultRemoveAllWithKeyWithCallRemoveAllDataKwMethod -#define LOCAL_DeeSeq_DefaultRemoveIfWithCallAttrRemoveIf DeeSeq_DefaultRemoveIfWithCallRemoveIfDataKwMethod -#define LOCAL_DeeSeq_DefaultResizeWithCallAttrResize DeeSeq_DefaultResizeWithCallResizeDataKwMethod -#define LOCAL_DeeSeq_DefaultFillWithCallAttrFill DeeSeq_DefaultFillWithCallFillDataKwMethod -#define LOCAL_DeeSeq_DefaultReverseWithCallAttrReverse DeeSeq_DefaultReverseWithCallReverseDataKwMethod -#define LOCAL_DeeSeq_DefaultReversedWithCallAttrReversed DeeSeq_DefaultReversedWithCallReversedDataKwMethod -#define LOCAL_DeeSeq_DefaultSortWithCallAttrSort DeeSeq_DefaultSortWithCallSortDataKwMethod -#define LOCAL_DeeSeq_DefaultSortWithKeyWithCallAttrSort DeeSeq_DefaultSortWithKeyWithCallSortDataKwMethod -#define LOCAL_DeeSeq_DefaultSortedWithCallAttrSorted DeeSeq_DefaultSortedWithCallSortedDataKwMethod -#define LOCAL_DeeSeq_DefaultSortedWithKeyWithCallAttrSorted DeeSeq_DefaultSortedWithKeyWithCallSortedDataKwMethod +#define LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Foo, Bar) PP_CAT5(DeeSeq_Default, Foo, WithCall, Bar, DataKwMethod) #else /* DEFINE_DeeSeq_Default... */ #error "Invalid configuration" #endif /* !DEFINE_DeeSeq_Default... */ +#define LOCAL_DeeSeq_DefaultFindWithCallAttrFind LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Find, Find) +#define LOCAL_DeeSeq_DefaultFindWithKeyWithCallAttrFind LOCAL_DeeSeq_DefaultFooWithCallAttrBar(FindWithKey, Find) +#define LOCAL_DeeSeq_DefaultRFindWithCallAttrRFind LOCAL_DeeSeq_DefaultFooWithCallAttrBar(RFind, RFind) +#define LOCAL_DeeSeq_DefaultRFindWithKeyWithCallAttrRFind LOCAL_DeeSeq_DefaultFooWithCallAttrBar(RFindWithKey, RFind) +#define LOCAL_DeeSeq_DefaultEraseWithCallAttrErase LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Erase, Erase) +#define LOCAL_DeeSeq_DefaultInsertWithCallAttrInsert LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Insert, Insert) +#define LOCAL_DeeSeq_DefaultInsertAllWithCallAttrInsertAll LOCAL_DeeSeq_DefaultFooWithCallAttrBar(InsertAll, InsertAll) +#define LOCAL_DeeSeq_DefaultPushFrontWithCallAttrPushFront LOCAL_DeeSeq_DefaultFooWithCallAttrBar(PushFront, PushFront) +#define LOCAL_DeeSeq_DefaultAppendWithCallAttrAppend LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Append, Append) +#define LOCAL_DeeSeq_DefaultAppendWithCallAttrPushBack LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Append, PushBack) +#define LOCAL_DeeSeq_DefaultExtendWithCallAttrExtend LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Extend, Extend) +#define LOCAL_DeeSeq_DefaultXchItemIndexWithCallAttrXchItem LOCAL_DeeSeq_DefaultFooWithCallAttrBar(XchItemIndex, XchItem) +#define LOCAL_DeeSeq_DefaultClearWithCallAttrClear LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Clear, Clear) +#define LOCAL_DeeSeq_DefaultPopWithCallAttrPop LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Pop, Pop) +#define LOCAL_DeeSeq_DefaultRemoveWithCallAttrRemove LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Remove, Remove) +#define LOCAL_DeeSeq_DefaultRemoveWithKeyWithCallAttrRemove LOCAL_DeeSeq_DefaultFooWithCallAttrBar(RemoveWithKey, Remove) +#define LOCAL_DeeSeq_DefaultRRemoveWithCallAttrRRemove LOCAL_DeeSeq_DefaultFooWithCallAttrBar(RRemove, RRemove) +#define LOCAL_DeeSeq_DefaultRRemoveWithKeyWithCallAttrRRemove LOCAL_DeeSeq_DefaultFooWithCallAttrBar(RRemoveWithKey, RRemove) +#define LOCAL_DeeSeq_DefaultRemoveAllWithCallAttrRemoveAll LOCAL_DeeSeq_DefaultFooWithCallAttrBar(RemoveAll, RemoveAll) +#define LOCAL_DeeSeq_DefaultRemoveAllWithKeyWithCallAttrRemoveAll LOCAL_DeeSeq_DefaultFooWithCallAttrBar(RemoveAllWithKey, RemoveAll) +#define LOCAL_DeeSeq_DefaultRemoveIfWithCallAttrRemoveIf LOCAL_DeeSeq_DefaultFooWithCallAttrBar(RemoveIf, RemoveIf) +#define LOCAL_DeeSeq_DefaultResizeWithCallAttrResize LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Resize, Resize) +#define LOCAL_DeeSeq_DefaultFillWithCallAttrFill LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Fill, Fill) +#define LOCAL_DeeSeq_DefaultReverseWithCallAttrReverse LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Reverse, Reverse) +#define LOCAL_DeeSeq_DefaultReversedWithCallAttrReversed LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Reversed, Reversed) +#define LOCAL_DeeSeq_DefaultSortWithCallAttrSort LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Sort, Sort) +#define LOCAL_DeeSeq_DefaultSortWithKeyWithCallAttrSort LOCAL_DeeSeq_DefaultFooWithCallAttrBar(SortWithKey, Sort) +#define LOCAL_DeeSeq_DefaultSortedWithCallAttrSorted LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Sorted, Sorted) +#define LOCAL_DeeSeq_DefaultSortedWithKeyWithCallAttrSorted LOCAL_DeeSeq_DefaultFooWithCallAttrBar(SortedWithKey, Sorted) +#define LOCAL_DeeSeq_DefaultBFindWithCallAttrBFind LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BFind, BFind) +#define LOCAL_DeeSeq_DefaultBFindWithKeyWithCallAttrBFind LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BFindWithKey, BFind) +#define LOCAL_DeeSeq_DefaultBPositionWithCallAttrBPosition LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BPosition, BPosition) +#define LOCAL_DeeSeq_DefaultBPositionWithKeyWithCallAttrBPosition LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BPositionWithKey, BPosition) +#define LOCAL_DeeSeq_DefaultBRangeWithCallAttrBRange LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BRange, BRange) +#define LOCAL_DeeSeq_DefaultBRangeWithKeyWithCallAttrBRange LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BRangeWithKey, BRange) +#define LOCAL_DeeSeq_DefaultBLocateWithCallAttrBLocate LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BLocate, BLocate) +#define LOCAL_DeeSeq_DefaultBLocateWithKeyWithCallAttrBLocate LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BLocateWithKey, BLocate) + #ifdef DEFINE_DeeSeq_DefaultFooWithCallAttrFoo @@ -188,50 +117,78 @@ DECL_BEGIN INTERN WUNUSED NONNULL((1, 2)) size_t DCALL LOCAL_DeeSeq_DefaultFindWithCallAttrFind(DeeObject *self, DeeObject *item, size_t start, size_t end) { + int temp; + Dee_ssize_t result_index; DREF DeeObject *result; result = LOCAL_DeeObject_CallAttrf(self, tsc_find_data, &str_find, "o" PCKuSIZ PCKuSIZ, item, start, end); if unlikely(!result) goto err; + temp = DeeObject_AsSSize(result, &result_index); Dee_Decref(result); - return 0; + if unlikely(temp) + goto err; + if unlikely(result_index == Dee_COMPARE_ERR) + err_integer_overflow_i(sizeof(size_t) * 8, true); + return (size_t)result_index; err: - return (size_t)-1; + return (size_t)Dee_COMPARE_ERR; } INTERN WUNUSED NONNULL((1, 2, 5)) size_t DCALL LOCAL_DeeSeq_DefaultFindWithKeyWithCallAttrFind(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key) { + int temp; + Dee_ssize_t result_index; DREF DeeObject *result; result = LOCAL_DeeObject_CallAttrf(self, tsc_find_data, &str_find, "o" PCKuSIZ PCKuSIZ "o", item, start, end, key); if unlikely(!result) goto err; + temp = DeeObject_AsSSize(result, &result_index); Dee_Decref(result); - return 0; + if unlikely(temp) + goto err; + if unlikely(result_index == Dee_COMPARE_ERR) + err_integer_overflow_i(sizeof(size_t) * 8, true); + return (size_t)result_index; err: - return (size_t)-1; + return (size_t)Dee_COMPARE_ERR; } INTERN WUNUSED NONNULL((1, 2)) size_t DCALL LOCAL_DeeSeq_DefaultRFindWithCallAttrRFind(DeeObject *self, DeeObject *item, size_t start, size_t end) { + int temp; + Dee_ssize_t result_index; DREF DeeObject *result; result = LOCAL_DeeObject_CallAttrf(self, tsc_rfind_data, &str_rfind, "o" PCKuSIZ PCKuSIZ, item, start, end); if unlikely(!result) goto err; + temp = DeeObject_AsSSize(result, &result_index); Dee_Decref(result); - return 0; + if unlikely(temp) + goto err; + if unlikely(result_index == Dee_COMPARE_ERR) + err_integer_overflow_i(sizeof(size_t) * 8, true); + return (size_t)result_index; err: - return (size_t)-1; + return (size_t)Dee_COMPARE_ERR; } INTERN WUNUSED NONNULL((1, 2, 5)) size_t DCALL LOCAL_DeeSeq_DefaultRFindWithKeyWithCallAttrRFind(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key) { + int temp; + Dee_ssize_t result_index; DREF DeeObject *result; result = LOCAL_DeeObject_CallAttrf(self, tsc_rfind_data, &str_rfind, "o" PCKuSIZ PCKuSIZ "o", item, start, end, key); if unlikely(!result) goto err; + temp = DeeObject_AsSSize(result, &result_index); Dee_Decref(result); - return 0; + if unlikely(temp) + goto err; + if unlikely(result_index == Dee_COMPARE_ERR) + err_integer_overflow_i(sizeof(size_t) * 8, true); + return (size_t)result_index; err: - return (size_t)-1; + return (size_t)Dee_COMPARE_ERR; } INTERN WUNUSED NONNULL((1)) int DCALL @@ -322,7 +279,7 @@ err: INTERN WUNUSED NONNULL((1, 3)) DREF DeeObject *DCALL LOCAL_DeeSeq_DefaultXchItemIndexWithCallAttrXchItem(DeeObject *self, size_t index, DeeObject *value) { - return LOCAL_DeeObject_CallAttrf(self, tsc_xchitem_index_data, &str_xchitem, PCKuSIZ "o", index, value); + return LOCAL_DeeObject_CallAttrf(self, tsc_xchitem_data, &str_xchitem, PCKuSIZ "o", index, value); } INTERN WUNUSED NONNULL((1)) int DCALL @@ -549,6 +506,154 @@ LOCAL_DeeSeq_DefaultSortedWithKeyWithCallAttrSorted(DeeObject *self, size_t star PCKuSIZ PCKuSIZ "o", start, end, key); } +INTERN WUNUSED NONNULL((1, 2)) size_t DCALL +LOCAL_DeeSeq_DefaultBFindWithCallAttrBFind(DeeObject *self, DeeObject *item, + size_t start, size_t end) { + int temp; + size_t result_index; + DREF DeeObject *result; + result = LOCAL_DeeObject_CallAttrf(self, tsc_bfind_data, &str_bfind, "o" PCKuSIZ PCKuSIZ, item, start, end); + if unlikely(!result) + goto err; + if (DeeNone_Check(result)) { + Dee_DecrefNokill(Dee_None); + return (size_t)-1; + } + temp = DeeObject_AsSize(result, &result_index); + Dee_Decref(result); + if unlikely(temp) + goto err; + if unlikely(result_index == (size_t)Dee_COMPARE_ERR) + err_integer_overflow_i(sizeof(size_t) * 8, true); + return (size_t)result_index; +err: + return (size_t)Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2, 5)) size_t DCALL +LOCAL_DeeSeq_DefaultBFindWithKeyWithCallAttrBFind(DeeObject *self, DeeObject *item, + size_t start, size_t end, DeeObject *key) { + int temp; + size_t result_index; + DREF DeeObject *result; + result = LOCAL_DeeObject_CallAttrf(self, tsc_bfind_data, &str_bfind, "o" PCKuSIZ PCKuSIZ "o", item, start, end, key); + if unlikely(!result) + goto err; + if (DeeNone_Check(result)) { + Dee_DecrefNokill(Dee_None); + return (size_t)-1; + } + temp = DeeObject_AsSize(result, &result_index); + Dee_Decref(result); + if unlikely(temp) + goto err; + if unlikely(result_index == (size_t)Dee_COMPARE_ERR) + err_integer_overflow_i(sizeof(size_t) * 8, true); + return (size_t)result_index; +err: + return (size_t)Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2)) size_t DCALL +LOCAL_DeeSeq_DefaultBPositionWithCallAttrBPosition(DeeObject *self, DeeObject *item, + size_t start, size_t end) { + int temp; + size_t result_index; + DREF DeeObject *result; + result = LOCAL_DeeObject_CallAttrf(self, tsc_bposition_data, &str_bposition, "o" PCKuSIZ PCKuSIZ, item, start, end); + if unlikely(!result) + goto err; + temp = DeeObject_AsSize(result, &result_index); + Dee_Decref(result); + if unlikely(temp) + goto err; + if unlikely(result_index == (size_t)Dee_COMPARE_ERR) + err_integer_overflow_i(sizeof(size_t) * 8, true); + return (size_t)result_index; +err: + return (size_t)Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2, 5)) size_t DCALL +LOCAL_DeeSeq_DefaultBPositionWithKeyWithCallAttrBPosition(DeeObject *self, DeeObject *item, + size_t start, size_t end, DeeObject *key) { + int temp; + size_t result_index; + DREF DeeObject *result; + result = LOCAL_DeeObject_CallAttrf(self, tsc_bposition_data, &str_bposition, "o" PCKuSIZ PCKuSIZ "o", item, start, end, key); + if unlikely(!result) + goto err; + temp = DeeObject_AsSize(result, &result_index); + Dee_Decref(result); + if unlikely(temp) + goto err; + if unlikely(result_index == (size_t)Dee_COMPARE_ERR) + err_integer_overflow_i(sizeof(size_t) * 8, true); + return (size_t)result_index; +err: + return (size_t)Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2, 5)) int DCALL +LOCAL_DeeSeq_DefaultBRangeWithCallAttrBRange(DeeObject *self, DeeObject *item, + size_t start, size_t end, size_t result_range[2]) { + int temp; + DREF DeeObject *result, *result_range_objs[2]; + result = LOCAL_DeeObject_CallAttrf(self, tsc_brange_data, &str_brange, "o" PCKuSIZ PCKuSIZ, item, start, end); + if unlikely(!result) + goto err; + temp = DeeObject_Unpack(result, 2, result_range_objs); + Dee_Decref(result); + if unlikely(temp) + goto err; + temp = DeeObject_AsSize(result_range_objs[0], &result_range[0]); + if likely(temp == 0) + temp = DeeObject_AsSize(result_range_objs[1], &result_range[1]); + Dee_Decrefv(result_range_objs, 2); + if unlikely(temp) + goto err; + return 0; +err: + return -1; +} + +INTERN WUNUSED NONNULL((1, 2, 5, 6)) int DCALL +LOCAL_DeeSeq_DefaultBRangeWithKeyWithCallAttrBRange(DeeObject *self, DeeObject *item, + size_t start, size_t end, DeeObject *key, + size_t result_range[2]) { + int temp; + DREF DeeObject *result, *result_range_objs[2]; + result = LOCAL_DeeObject_CallAttrf(self, tsc_brange_data, &str_brange, "o" PCKuSIZ PCKuSIZ "o", item, start, end, key); + if unlikely(!result) + goto err; + temp = DeeObject_Unpack(result, 2, result_range_objs); + Dee_Decref(result); + if unlikely(temp) + goto err; + temp = DeeObject_AsSize(result_range_objs[0], &result_range[0]); + if likely(temp == 0) + temp = DeeObject_AsSize(result_range_objs[1], &result_range[1]); + Dee_Decrefv(result_range_objs, 2); + if unlikely(temp) + goto err; + return 0; +err: + return -1; +} + +INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL +LOCAL_DeeSeq_DefaultBLocateWithCallAttrBLocate(DeeObject *self, DeeObject *item, + size_t start, size_t end) { + return LOCAL_DeeObject_CallAttrf(self, tsc_blocate_data, &str_blocate, "o" PCKuSIZ PCKuSIZ, item, start, end); +} + +INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL +LOCAL_DeeSeq_DefaultBLocateWithKeyWithCallAttrBLocate(DeeObject *self, DeeObject *item, + size_t start, size_t end, DeeObject *key) { + return LOCAL_DeeObject_CallAttrf(self, tsc_blocate_data, &str_blocate, "o" PCKuSIZ PCKuSIZ "o", item, start, end, key); +} + + #undef LOCAL_DeeObject_CallAttr #undef LOCAL_DeeObject_CallAttrf @@ -581,6 +686,16 @@ LOCAL_DeeSeq_DefaultSortedWithKeyWithCallAttrSorted(DeeObject *self, size_t star #undef LOCAL_DeeSeq_DefaultSortWithKeyWithCallAttrSort #undef LOCAL_DeeSeq_DefaultSortedWithCallAttrSorted #undef LOCAL_DeeSeq_DefaultSortedWithKeyWithCallAttrSorted +#undef LOCAL_DeeSeq_DefaultBFindWithCallAttrBFind +#undef LOCAL_DeeSeq_DefaultBFindWithKeyWithCallAttrBFind +#undef LOCAL_DeeSeq_DefaultBPositionWithCallAttrBPosition +#undef LOCAL_DeeSeq_DefaultBPositionWithKeyWithCallAttrBPosition +#undef LOCAL_DeeSeq_DefaultBRangeWithCallAttrBRange +#undef LOCAL_DeeSeq_DefaultBRangeWithKeyWithCallAttrBRange +#undef LOCAL_DeeSeq_DefaultBLocateWithCallAttrBLocate +#undef LOCAL_DeeSeq_DefaultBLocateWithKeyWithCallAttrBLocate + +#undef LOCAL_DeeSeq_DefaultFooWithCallAttrBar DECL_END diff --git a/src/deemon/objects/seq/default-api-methods-bsearch-impl.c.inl b/src/deemon/objects/seq/default-api-methods-bsearch-impl.c.inl new file mode 100644 index 000000000..3a3d1cbd1 --- /dev/null +++ b/src/deemon/objects/seq/default-api-methods-bsearch-impl.c.inl @@ -0,0 +1,319 @@ +/* Copyright (c) 2018-2024 Griefer@Work * + * * + * This software is provided 'as-is', without any express or implied * + * warranty. In no event will the authors be held liable for any damages * + * arising from the use of this software. * + * * + * Permission is granted to anyone to use this software for any purpose, * + * including commercial applications, and to alter it and redistribute it * + * freely, subject to the following restrictions: * + * * + * 1. The origin of this software must not be misrepresented; you must not * + * claim that you wrote the original software. If you use this software * + * in a product, an acknowledgement (see the following) in the product * + * documentation is required: * + * Portions Copyright (c) 2018-2024 Griefer@Work * + * 2. Altered source versions must be plainly marked as such, and must not be * + * misrepresented as being the original software. * + * 3. This notice may not be removed or altered from any source distribution. * + */ +#ifdef __INTELLISENSE__ +#include "default-api-methods.c" +//#define DEFINE_DeeSeq_DefaultBFindWithSizeAndTryGetItemIndex +//#define DEFINE_DeeSeq_DefaultBFindWithKeyWithSizeAndTryGetItemIndex +//#define DEFINE_DeeSeq_DefaultBPositionWithSizeAndTryGetItemIndex +//#define DEFINE_DeeSeq_DefaultBPositionWithKeyWithSizeAndTryGetItemIndex +//#define DEFINE_DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex +#define DEFINE_DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex +//#define DEFINE_DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex +//#define DEFINE_DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex +#endif /* __INTELLISENSE__ */ + +#if (defined(DEFINE_DeeSeq_DefaultBFindWithSizeAndTryGetItemIndex) + \ + defined(DEFINE_DeeSeq_DefaultBFindWithKeyWithSizeAndTryGetItemIndex) + \ + defined(DEFINE_DeeSeq_DefaultBPositionWithSizeAndTryGetItemIndex) + \ + defined(DEFINE_DeeSeq_DefaultBPositionWithKeyWithSizeAndTryGetItemIndex) + \ + defined(DEFINE_DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex) + \ + defined(DEFINE_DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex) + \ + defined(DEFINE_DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex) + \ + defined(DEFINE_DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex)) != 1 +#error "Must #define exactly one of these macros" +#endif /* DEFINE_DeeSeq_DefaultB... */ + + +DECL_BEGIN + +#ifdef DEFINE_DeeSeq_DefaultBFindWithSizeAndTryGetItemIndex +#define LOCAL_DeeSeq_DefaultBFind DeeSeq_DefaultBFindWithSizeAndTryGetItemIndex +#define LOCAL_IS_FIND +#elif defined(DEFINE_DeeSeq_DefaultBFindWithKeyWithSizeAndTryGetItemIndex) +#define LOCAL_DeeSeq_DefaultBFind DeeSeq_DefaultBFindWithKeyWithSizeAndTryGetItemIndex +#define LOCAL_IS_FIND +#define LOCAL_HAS_KEY +#elif defined(DEFINE_DeeSeq_DefaultBPositionWithSizeAndTryGetItemIndex) +#define LOCAL_DeeSeq_DefaultBFind DeeSeq_DefaultBPositionWithSizeAndTryGetItemIndex +#define LOCAL_IS_POSITION +#elif defined(DEFINE_DeeSeq_DefaultBPositionWithKeyWithSizeAndTryGetItemIndex) +#define LOCAL_DeeSeq_DefaultBFind DeeSeq_DefaultBPositionWithKeyWithSizeAndTryGetItemIndex +#define LOCAL_IS_POSITION +#define LOCAL_HAS_KEY +#elif defined(DEFINE_DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex) +#define LOCAL_DeeSeq_DefaultBFind DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex +#define LOCAL_IS_RANGE +#elif defined(DEFINE_DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex) +#define LOCAL_DeeSeq_DefaultBFind DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex +#define LOCAL_IS_RANGE +#define LOCAL_HAS_KEY +#elif defined(DEFINE_DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex) +#define LOCAL_DeeSeq_DefaultBFind DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex +#define LOCAL_IS_LOCATE +#elif defined(DEFINE_DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex) +#define LOCAL_DeeSeq_DefaultBFind DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex +#define LOCAL_IS_LOCATE +#define LOCAL_HAS_KEY +#else /* DEFINE_DeeSeq_DefaultB... */ +#error "Invalid configuration" +#endif /* !DEFINE_DeeSeq_DefaultB... */ + +#if defined(LOCAL_IS_FIND) || defined(LOCAL_IS_POSITION) +#define LOCAL_return_t size_t +#define LOCAL_return_ERR (size_t)Dee_COMPARE_ERR +#elif defined(LOCAL_IS_LOCATE) +#define LOCAL_return_t DREF DeeObject * +#define LOCAL_return_ERR NULL +#else /* LOCAL_IS_FIND || LOCAL_IS_POSITION */ +#define LOCAL_return_t int +#define LOCAL_return_ERR (-1) +#endif /* !LOCAL_IS_FIND && !LOCAL_IS_POSITION */ + + +#ifndef overflowsafe_mid_DEFINED +#define overflowsafe_mid_DEFINED +LOCAL ATTR_CONST size_t overflowsafe_mid(size_t a, size_t b) { + size_t result; + if unlikely(OVERFLOW_UADD(a, b, &result)) { + size_t a_div2 = a >> 1; + size_t b_div2 = b >> 1; + result = (a_div2 + b_div2); + if ((a & 1) && (b & 1)) + ++result; + return result; + } + return result >> 1; +} +#endif /* !overflowsafe_mid_DEFINED */ + + + +INTERN WUNUSED LOCAL_return_t DCALL +LOCAL_DeeSeq_DefaultBFind(DeeObject *self, DeeObject *item, + size_t start, size_t end +#ifdef LOCAL_HAS_KEY + , DeeObject *key +#endif /* LOCAL_HAS_KEY */ +#ifdef LOCAL_IS_RANGE + , size_t result_range[2] +#endif /* LOCAL_IS_RANGE */ + ) { +#if defined(LOCAL_IS_LOCATE) && defined(LOCAL_HAS_KEY) + DeeObject *orig_item = item; +#endif /* LOCAL_IS_LOCATE && LOCAL_HAS_KEY */ + struct type_seq *seq = Dee_TYPE(self)->tp_seq; + size_t selfsize = (*seq->tp_size)(self); + if unlikely(selfsize == (size_t)-1) + goto err_item; + if (end > selfsize) + end = selfsize; + if likely(start < end) { +#ifdef LOCAL_HAS_KEY + item = DeeObject_Call(key, 1, &item); + if unlikely(!item) + goto err; +#define WANT_err +#endif /* LOCAL_HAS_KEY */ + do { + int cmp_result; + size_t mid = overflowsafe_mid(start, end); + DREF DeeObject *seq_item = (*seq->tp_trygetitem_index)(self, mid); + if unlikely(!ITER_ISOK(seq_item)) { + if unlikely(!seq_item) + goto err_item; + cmp_result = 1; /* item > */ + } else { +#ifdef LOCAL_HAS_KEY + cmp_result = DeeObject_CompareKey(item, seq_item, key); +#else /* LOCAL_HAS_KEY */ + cmp_result = DeeObject_Compare(item, seq_item); +#endif /* !LOCAL_HAS_KEY */ + +#ifndef LOCAL_IS_LOCATE + Dee_Decref(seq_item); +#endif /* !LOCAL_IS_LOCATE */ + if unlikely(cmp_result == Dee_COMPARE_ERR) { +#ifdef LOCAL_IS_LOCATE + Dee_Decref(seq_item); +#endif /* !LOCAL_IS_LOCATE */ + goto err_item; + } + } + if (cmp_result < 0) { + end = mid; + } else if (cmp_result > 0) { + start = mid + 1; + } else { + /* Found it! (at "mid") */ + +#if defined(LOCAL_IS_FIND) || defined(LOCAL_IS_POSITION) + ASSERTF(mid != (size_t)-1, "Impossible, because `mid < end', it can't be SIZE_MAX!"); + if unlikely(mid == (size_t)Dee_COMPARE_ERR) + goto err_item_overflow; +#define WANT_err_item_overflow +#ifdef LOCAL_HAS_KEY + Dee_Decref(item); +#endif /* LOCAL_HAS_KEY */ + return mid; +#elif defined(LOCAL_IS_LOCATE) +#ifdef LOCAL_HAS_KEY + Dee_Decref(item); +#endif /* LOCAL_HAS_KEY */ + return seq_item; +#elif defined(LOCAL_IS_RANGE) + size_t result_range_start = mid; + size_t result_range_end = mid + 1; + + /* Widen the result range's lower bound */ + while (result_range_start > start) { + mid = overflowsafe_mid(start, result_range_start); + seq_item = (*seq->tp_trygetitem_index)(self, mid); + if unlikely(!ITER_ISOK(seq_item)) { + if unlikely(!seq_item) + goto err_item; + cmp_result = 1; /* item > */ + } else { +#ifdef LOCAL_HAS_KEY + cmp_result = DeeObject_TryCompareKeyEq(item, seq_item, key); +#else /* LOCAL_HAS_KEY */ + cmp_result = DeeObject_TryCompareEq(item, seq_item); +#endif /* !LOCAL_HAS_KEY */ + Dee_Decref(seq_item); + if unlikely(cmp_result == Dee_COMPARE_ERR) + goto err_item; + } + if (cmp_result == 0) { + /* Still part of returned range! */ + result_range_start = mid; + } else { + /* No longer part of returned range! */ + start = mid + 1; + } + /* Since this runs in O(log(N)), there's no need to check for interrupts! */ + } + + /* Widen the result range's upper bound */ + while (result_range_end < end) { + mid = overflowsafe_mid(result_range_end, end); + seq_item = (*seq->tp_trygetitem_index)(self, mid); + if unlikely(!ITER_ISOK(seq_item)) { + if unlikely(!seq_item) + goto err_item; + cmp_result = 1; /* item > */ + } else { +#ifdef LOCAL_HAS_KEY + cmp_result = DeeObject_TryCompareKeyEq(item, seq_item, key); +#else /* LOCAL_HAS_KEY */ + cmp_result = DeeObject_TryCompareEq(item, seq_item); +#endif /* !LOCAL_HAS_KEY */ + Dee_Decref(seq_item); + if unlikely(cmp_result == Dee_COMPARE_ERR) + goto err_item; + } + if (cmp_result == 0) { + /* Still part of returned range! */ + result_range_end = mid + 1; + } else { + /* No longer part of returned range! */ + end = mid; + } + /* Since this runs in O(log(N)), there's no need to check for interrupts! */ + } + + /* Write-back the result range bounds */ + result_range[0] = result_range_start; + result_range[1] = result_range_end; +#ifdef LOCAL_HAS_KEY + Dee_Decref(item); +#endif /* LOCAL_HAS_KEY */ + return 0; +#else /* LOCAL_IS_... */ +#error "Invalid configuration" +#endif /* !LOCAL_IS_... */ + } +#ifdef LOCAL_IS_LOCATE + Dee_Decref(seq_item); +#endif /* !LOCAL_IS_LOCATE */ + + /* Since this runs in O(log(N)), there's no need to check for interrupts! */ + } while (start < end); + +#ifdef LOCAL_HAS_KEY + Dee_Decref(item); +#endif /* LOCAL_HAS_KEY */ + } +#ifdef LOCAL_IS_FIND + return (size_t)-1; /* Not found */ +#elif defined(LOCAL_IS_POSITION) + ASSERT(start == end); + if unlikely(start == (size_t)-1 || start == (size_t)Dee_COMPARE_ERR) + goto err_item_overflow; + return start; +#elif defined(LOCAL_IS_LOCATE) +#ifdef LOCAL_HAS_KEY + err_item_not_found(self, orig_item); +#else /* LOCAL_HAS_KEY */ + err_item_not_found(self, item); +#endif /* !LOCAL_HAS_KEY */ + goto err; +#define WANT_err +#elif defined(LOCAL_IS_RANGE) + result_range[0] = start; + result_range[1] = end; + return 0; +#else /* LOCAL_IS_... */ +#error "Invalid configuration" +#endif /* !LOCAL_IS_... */ +#ifdef WANT_err_item_overflow +#undef WANT_err_item_overflow +err_item_overflow: + err_integer_overflow_i(sizeof(size_t) * 8, true); +#endif /* WANT_err_item_overflow */ +err_item: +#ifdef LOCAL_HAS_KEY + Dee_Decref(item); +#endif /* LOCAL_HAS_KEY */ +#ifdef WANT_err +#undef WANT_err +err: +#endif /* WANT_err */ + return LOCAL_return_ERR; +} + +#undef LOCAL_return_t +#undef LOCAL_return_ERR + +#undef LOCAL_DeeSeq_DefaultBFind +#undef LOCAL_HAS_KEY +#undef LOCAL_IS_FIND +#undef LOCAL_IS_POSITION +#undef LOCAL_IS_RANGE +#undef LOCAL_IS_LOCATE + +DECL_END + +#undef DEFINE_DeeSeq_DefaultBFindWithSizeAndTryGetItemIndex +#undef DEFINE_DeeSeq_DefaultBFindWithKeyWithSizeAndTryGetItemIndex +#undef DEFINE_DeeSeq_DefaultBPositionWithSizeAndTryGetItemIndex +#undef DEFINE_DeeSeq_DefaultBPositionWithKeyWithSizeAndTryGetItemIndex +#undef DEFINE_DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex +#undef DEFINE_DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex +#undef DEFINE_DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex +#undef DEFINE_DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex diff --git a/src/deemon/objects/seq/default-api-methods-require-impl.c.inl b/src/deemon/objects/seq/default-api-methods-require-impl.c.inl index 5e28dc837..34e4cad79 100644 --- a/src/deemon/objects/seq/default-api-methods-require-impl.c.inl +++ b/src/deemon/objects/seq/default-api-methods-require-impl.c.inl @@ -33,7 +33,7 @@ //#define DEFINE_DeeType_SeqCache_RequireClear //#define DEFINE_DeeType_SeqCache_RequirePop //#define DEFINE_DeeType_SeqCache_RequireRemove -#define DEFINE_DeeType_SeqCache_RequireRemoveWithKey +//#define DEFINE_DeeType_SeqCache_RequireRemoveWithKey //#define DEFINE_DeeType_SeqCache_RequireRRemove //#define DEFINE_DeeType_SeqCache_RequireRRemoveWithKey //#define DEFINE_DeeType_SeqCache_RequireRemoveAll @@ -47,6 +47,14 @@ //#define DEFINE_DeeType_SeqCache_RequireSortWithKey //#define DEFINE_DeeType_SeqCache_RequireSorted //#define DEFINE_DeeType_SeqCache_RequireSortedWithKey +//#define DEFINE_DeeType_SeqCache_RequireBFind +#define DEFINE_DeeType_SeqCache_RequireBFindWithKey +//#define DEFINE_DeeType_SeqCache_RequireBPosition +//#define DEFINE_DeeType_SeqCache_RequireBPositionWithKey +//#define DEFINE_DeeType_SeqCache_RequireBRange +//#define DEFINE_DeeType_SeqCache_RequireBRangeWithKey +//#define DEFINE_DeeType_SeqCache_RequireBLocate +//#define DEFINE_DeeType_SeqCache_RequireBLocateWithKey #endif /* __INTELLISENSE__ */ #if (defined(DEFINE_DeeType_SeqCache_RequireFind) + \ @@ -76,307 +84,276 @@ defined(DEFINE_DeeType_SeqCache_RequireSort) + \ defined(DEFINE_DeeType_SeqCache_RequireSortWithKey) + \ defined(DEFINE_DeeType_SeqCache_RequireSorted) + \ - defined(DEFINE_DeeType_SeqCache_RequireSortedWithKey)) != 1 + defined(DEFINE_DeeType_SeqCache_RequireSortedWithKey) + \ + defined(DEFINE_DeeType_SeqCache_RequireBFind) + \ + defined(DEFINE_DeeType_SeqCache_RequireBFindWithKey) + \ + defined(DEFINE_DeeType_SeqCache_RequireBPosition) + \ + defined(DEFINE_DeeType_SeqCache_RequireBPositionWithKey) + \ + defined(DEFINE_DeeType_SeqCache_RequireBRange) + \ + defined(DEFINE_DeeType_SeqCache_RequireBRangeWithKey) + \ + defined(DEFINE_DeeType_SeqCache_RequireBLocate) + \ + defined(DEFINE_DeeType_SeqCache_RequireBLocateWithKey)) != 1 #error "Must #define exactly one of these macros" #endif /* DEFINE_DeeType_SeqCache_Require... */ DECL_BEGIN #ifdef DEFINE_DeeType_SeqCache_RequireFind -#define LOCAL_CANONICAL_NAME find -#define LOCAL_generic_seq_foo generic_seq_find -#define LOCAL_tsc_foo tsc_find -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireFind -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultFindWithCallAttrFind -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultFindWithCallFindDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultFindWithCallFindDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultFindWithCallFindDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultFindWithEnumerateIndex +#define LOCAL_CANONICAL_NAME find +#define LOCAL_generic_seq_foo generic_seq_find +#define LOCAL_tsc_foo tsc_find +#define LOCAL_DeeSeq_AttrFoo Find +#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultFindWithEnumerateIndex #elif defined(DEFINE_DeeType_SeqCache_RequireFindWithKey) -#define LOCAL_CANONICAL_NAME find -#define LOCAL_generic_seq_foo generic_seq_find -#define LOCAL_tsc_foo tsc_find_with_key -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireFindWithKey -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultFindWithKeyWithCallAttrFind -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultFindWithKeyWithCallFindDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultFindWithKeyWithCallFindDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultFindWithKeyWithCallFindDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultFindWithKeyWithEnumerateIndex +#define LOCAL_CANONICAL_NAME find +#define LOCAL_generic_seq_foo generic_seq_find +#define LOCAL_tsc_foo tsc_find_with_key +#define LOCAL_DeeSeq_AttrFoo FindWithKey +#define LOCAL_DeeSeq_AttrBar Find +#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultFindWithKeyWithEnumerateIndex #elif defined(DEFINE_DeeType_SeqCache_RequireRFind) -#define LOCAL_CANONICAL_NAME rfind -#define LOCAL_generic_seq_foo generic_seq_rfind -#define LOCAL_tsc_foo tsc_rfind -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireRFind -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultRFindWithCallAttrRFind -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultRFindWithCallRFindDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultRFindWithCallRFindDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultRFindWithCallRFindDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRFindWithEnumerateIndex +#define LOCAL_CANONICAL_NAME rfind +#define LOCAL_generic_seq_foo generic_seq_rfind +#define LOCAL_tsc_foo tsc_rfind +#define LOCAL_DeeSeq_AttrFoo RFind +#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRFindWithEnumerateIndex #elif defined(DEFINE_DeeType_SeqCache_RequireRFindWithKey) -#define LOCAL_CANONICAL_NAME rfind -#define LOCAL_generic_seq_foo generic_seq_rfind -#define LOCAL_tsc_foo tsc_rfind_with_key -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireRFindWithKey -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultRFindWithKeyWithCallAttrRFind -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultRFindWithKeyWithCallRFindDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultRFindWithKeyWithCallRFindDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultRFindWithKeyWithCallRFindDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRFindWithKeyWithEnumerateIndex +#define LOCAL_CANONICAL_NAME rfind +#define LOCAL_generic_seq_foo generic_seq_rfind +#define LOCAL_tsc_foo tsc_rfind_with_key +#define LOCAL_DeeSeq_AttrFoo RFindWithKey +#define LOCAL_DeeSeq_AttrBar RFind +#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRFindWithKeyWithEnumerateIndex #elif defined(DEFINE_DeeType_SeqCache_RequireErase) -#define LOCAL_CANONICAL_NAME erase -#define LOCAL_generic_seq_foo generic_seq_erase -#define LOCAL_tsc_foo tsc_erase -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireErase -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultEraseWithCallAttrErase -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultEraseWithCallEraseDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultEraseWithCallEraseDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultEraseWithCallEraseDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultEraseWithError +#define LOCAL_CANONICAL_NAME erase +#define LOCAL_generic_seq_foo generic_seq_erase +#define LOCAL_tsc_foo tsc_erase +#define LOCAL_DeeSeq_AttrFoo Erase #elif defined(DEFINE_DeeType_SeqCache_RequireInsert) -#define LOCAL_CANONICAL_NAME insert -#define LOCAL_generic_seq_foo generic_seq_insert -#define LOCAL_tsc_foo tsc_insert -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireInsert -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultInsertWithCallAttrInsert -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultInsertWithCallInsertDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultInsertWithCallInsertDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultInsertWithCallInsertDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultInsertWithError +#define LOCAL_CANONICAL_NAME insert +#define LOCAL_generic_seq_foo generic_seq_insert +#define LOCAL_tsc_foo tsc_insert +#define LOCAL_DeeSeq_AttrFoo Insert #elif defined(DEFINE_DeeType_SeqCache_RequireInsertAll) -#define LOCAL_CANONICAL_NAME insertall -#define LOCAL_generic_seq_foo generic_seq_insertall -#define LOCAL_tsc_foo tsc_insertall -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireInsertAll -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultInsertAllWithCallAttrInsertAll -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultInsertAllWithCallInsertAllDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultInsertAllWithCallInsertAllDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultInsertAllWithCallInsertAllDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultInsertAllWithError +#define LOCAL_CANONICAL_NAME insertall +#define LOCAL_generic_seq_foo generic_seq_insertall +#define LOCAL_tsc_foo tsc_insertall +#define LOCAL_DeeSeq_AttrFoo InsertAll #elif defined(DEFINE_DeeType_SeqCache_RequirePushFront) -#define LOCAL_CANONICAL_NAME pushfront -#define LOCAL_generic_seq_foo generic_seq_pushfront -#define LOCAL_tsc_foo tsc_pushfront -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequirePushFront -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultPushFrontWithCallAttrPushFront -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultPushFrontWithCallPushFrontDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultPushFrontWithCallPushFrontDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultPushFrontWithCallPushFrontDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultPushFrontWithTSCInsert /* Use insert() by default */ +#define LOCAL_CANONICAL_NAME pushfront +#define LOCAL_generic_seq_foo generic_seq_pushfront +#define LOCAL_tsc_foo tsc_pushfront +#define LOCAL_DeeSeq_AttrFoo PushFront +#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultPushFrontWithTSCInsert /* Use insert() by default */ #elif defined(DEFINE_DeeType_SeqCache_RequireAppend) -#define LOCAL_CANONICAL_NAME append -#define LOCAL_generic_seq_foo generic_seq_append -#define LOCAL_tsc_foo tsc_append -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireAppend -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultAppendWithCallAttrAppend -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultAppendWithCallAppendDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultAppendWithCallAppendDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultAppendWithCallAppendDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultAppendWithError +#define LOCAL_CANONICAL_NAME append +#define LOCAL_generic_seq_foo generic_seq_append +#define LOCAL_tsc_foo tsc_append +#define LOCAL_DeeSeq_AttrFoo Append #elif defined(DEFINE_DeeType_SeqCache_RequireExtend) -#define LOCAL_CANONICAL_NAME extend -#define LOCAL_generic_seq_foo generic_seq_extend -#define LOCAL_tsc_foo tsc_extend -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireExtend -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultExtendWithCallAttrExtend -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultExtendWithCallExtendDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultExtendWithCallExtendDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultExtendWithCallExtendDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultExtendWithError +#define LOCAL_CANONICAL_NAME extend +#define LOCAL_generic_seq_foo generic_seq_extend +#define LOCAL_tsc_foo tsc_extend +#define LOCAL_DeeSeq_AttrFoo Extend #elif defined(DEFINE_DeeType_SeqCache_RequireXchItemIndex) -#define LOCAL_CANONICAL_NAME xchitem -#define LOCAL_generic_seq_foo generic_seq_xchitem -#define LOCAL_tsc_foo tsc_xchitem_index -#define LOCAL_tsc_foo_data tsc_xchitem_index_data -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireXchItemIndex -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultXchItemIndexWithCallAttrXchItem -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultXchItemIndexWithCallXchItemIndexDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultXchItemIndexWithCallXchItemIndexDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultXchItemIndexWithCallXchItemIndexDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultXchItemIndexWithError +#define LOCAL_CANONICAL_NAME xchitem +#define LOCAL_generic_seq_foo generic_seq_xchitem +#define LOCAL_tsc_foo tsc_xchitem_index +#define LOCAL_tsc_foo_data tsc_xchitem_data +#define LOCAL_DeeSeq_AttrFoo XchItemIndex +#define LOCAL_DeeSeq_AttrBar XchItem #elif defined(DEFINE_DeeType_SeqCache_RequireClear) -#define LOCAL_CANONICAL_NAME clear -#define LOCAL_generic_seq_foo generic_seq_clear -#define LOCAL_tsc_foo tsc_clear -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireClear -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultClearWithCallAttrClear -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultClearWithCallClearDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultClearWithCallClearDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultClearWithCallClearDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultClearWithError +#define LOCAL_CANONICAL_NAME clear +#define LOCAL_generic_seq_foo generic_seq_clear +#define LOCAL_tsc_foo tsc_clear +#define LOCAL_DeeSeq_AttrFoo Clear #elif defined(DEFINE_DeeType_SeqCache_RequirePop) -#define LOCAL_CANONICAL_NAME pop -#define LOCAL_generic_seq_foo generic_seq_pop -#define LOCAL_tsc_foo tsc_pop -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequirePop -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultPopWithCallAttrPop -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultPopWithCallPopDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultPopWithCallPopDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultPopWithCallPopDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultPopWithError +#define LOCAL_CANONICAL_NAME pop +#define LOCAL_generic_seq_foo generic_seq_pop +#define LOCAL_tsc_foo tsc_pop +#define LOCAL_DeeSeq_AttrFoo Pop #elif defined(DEFINE_DeeType_SeqCache_RequireRemove) -#define LOCAL_CANONICAL_NAME remove -#define LOCAL_generic_seq_foo generic_seq_remove -#define LOCAL_tsc_foo tsc_remove -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireRemove -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultRemoveWithCallAttrRemove -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultRemoveWithCallRemoveDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultRemoveWithCallRemoveDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultRemoveWithCallRemoveDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRemoveWithError +#define LOCAL_CANONICAL_NAME remove +#define LOCAL_generic_seq_foo generic_seq_remove +#define LOCAL_tsc_foo tsc_remove +#define LOCAL_DeeSeq_AttrFoo Remove #elif defined(DEFINE_DeeType_SeqCache_RequireRemoveWithKey) -#define LOCAL_CANONICAL_NAME remove -#define LOCAL_generic_seq_foo generic_seq_remove -#define LOCAL_tsc_foo tsc_remove_with_key -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireRemoveWithKey -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultRemoveWithKeyWithCallAttrRemove -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultRemoveWithKeyWithCallRemoveDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultRemoveWithKeyWithCallRemoveDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultRemoveWithKeyWithCallRemoveDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRemoveWithKeyWithError +#define LOCAL_CANONICAL_NAME remove +#define LOCAL_generic_seq_foo generic_seq_remove +#define LOCAL_tsc_foo tsc_remove_with_key +#define LOCAL_DeeSeq_AttrFoo RemoveWithKey +#define LOCAL_DeeSeq_AttrBar Remove #elif defined(DEFINE_DeeType_SeqCache_RequireRRemove) -#define LOCAL_CANONICAL_NAME rremove -#define LOCAL_generic_seq_foo generic_seq_rremove -#define LOCAL_tsc_foo tsc_rremove -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireRRemove -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultRRemoveWithCallAttrRRemove -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultRRemoveWithCallRRemoveDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultRRemoveWithCallRRemoveDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultRRemoveWithCallRRemoveDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRRemoveWithError +#define LOCAL_CANONICAL_NAME rremove +#define LOCAL_generic_seq_foo generic_seq_rremove +#define LOCAL_tsc_foo tsc_rremove +#define LOCAL_DeeSeq_AttrFoo RRemove #elif defined(DEFINE_DeeType_SeqCache_RequireRRemoveWithKey) -#define LOCAL_CANONICAL_NAME rremove -#define LOCAL_generic_seq_foo generic_seq_rremove -#define LOCAL_tsc_foo tsc_rremove_with_key -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireRRemoveWithKey -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultRRemoveWithKeyWithCallAttrRRemove -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultRRemoveWithKeyWithCallRRemoveDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultRRemoveWithKeyWithCallRRemoveDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultRRemoveWithKeyWithCallRRemoveDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRRemoveWithKeyWithError +#define LOCAL_CANONICAL_NAME rremove +#define LOCAL_generic_seq_foo generic_seq_rremove +#define LOCAL_tsc_foo tsc_rremove_with_key +#define LOCAL_DeeSeq_AttrFoo RRemoveWithKey +#define LOCAL_DeeSeq_AttrBar RRemove #elif defined(DEFINE_DeeType_SeqCache_RequireRemoveAll) -#define LOCAL_CANONICAL_NAME removeall -#define LOCAL_generic_seq_foo generic_seq_removeall -#define LOCAL_tsc_foo tsc_removeall -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireRemoveAll -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultRemoveAllWithCallAttrRemoveAll -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultRemoveAllWithCallRemoveAllDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultRemoveAllWithCallRemoveAllDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultRemoveAllWithCallRemoveAllDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRemoveAllWithError +#define LOCAL_CANONICAL_NAME removeall +#define LOCAL_generic_seq_foo generic_seq_removeall +#define LOCAL_tsc_foo tsc_removeall +#define LOCAL_DeeSeq_AttrFoo RemoveAll #elif defined(DEFINE_DeeType_SeqCache_RequireRemoveAllWithKey) -#define LOCAL_CANONICAL_NAME removeall -#define LOCAL_generic_seq_foo generic_seq_removeall -#define LOCAL_tsc_foo tsc_removeall_with_key -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireRemoveAllWithKey -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultRemoveAllWithKeyWithCallAttrRemoveAll -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultRemoveAllWithKeyWithCallRemoveAllDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultRemoveAllWithKeyWithCallRemoveAllDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultRemoveAllWithKeyWithCallRemoveAllDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRemoveAllWithKeyWithError +#define LOCAL_CANONICAL_NAME removeall +#define LOCAL_generic_seq_foo generic_seq_removeall +#define LOCAL_tsc_foo tsc_removeall_with_key +#define LOCAL_DeeSeq_AttrFoo RemoveAllWithKey +#define LOCAL_DeeSeq_AttrBar RemoveAll #elif defined(DEFINE_DeeType_SeqCache_RequireRemoveIf) -#define LOCAL_CANONICAL_NAME removeif -#define LOCAL_generic_seq_foo generic_seq_removeif -#define LOCAL_tsc_foo tsc_removeif -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireRemoveIf -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultRemoveIfWithCallAttrRemoveIf -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultRemoveIfWithCallRemoveIfDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultRemoveIfWithCallRemoveIfDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultRemoveIfWithCallRemoveIfDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRemoveIfWithError +#define LOCAL_CANONICAL_NAME removeif +#define LOCAL_generic_seq_foo generic_seq_removeif +#define LOCAL_tsc_foo tsc_removeif +#define LOCAL_DeeSeq_AttrFoo RemoveIf #elif defined(DEFINE_DeeType_SeqCache_RequireResize) -#define LOCAL_CANONICAL_NAME resize -#define LOCAL_generic_seq_foo generic_seq_resize -#define LOCAL_tsc_foo tsc_resize -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireResize -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultResizeWithCallAttrResize -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultResizeWithCallResizeDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultResizeWithCallResizeDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultResizeWithCallResizeDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultResizeWithSizeAndTSCEraseAndTSCExtend /* Use erase() and extend() by default */ +#define LOCAL_CANONICAL_NAME resize +#define LOCAL_generic_seq_foo generic_seq_resize +#define LOCAL_tsc_foo tsc_resize +#define LOCAL_DeeSeq_AttrFoo Resize +#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultResizeWithSizeAndTSCEraseAndTSCExtend /* Use erase() and extend() by default */ #elif defined(DEFINE_DeeType_SeqCache_RequireFill) -#define LOCAL_CANONICAL_NAME fill -#define LOCAL_generic_seq_foo generic_seq_fill -#define LOCAL_tsc_foo tsc_fill -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireFill -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultFillWithCallAttrFill -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultFillWithCallFillDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultFillWithCallFillDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultFillWithCallFillDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultFillWithError +#define LOCAL_CANONICAL_NAME fill +#define LOCAL_generic_seq_foo generic_seq_fill +#define LOCAL_tsc_foo tsc_fill +#define LOCAL_DeeSeq_AttrFoo Fill #elif defined(DEFINE_DeeType_SeqCache_RequireReverse) -#define LOCAL_CANONICAL_NAME reverse -#define LOCAL_generic_seq_foo generic_seq_reverse -#define LOCAL_tsc_foo tsc_reverse -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireReverse -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultReverseWithCallAttrReverse -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultReverseWithCallReverseDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultReverseWithCallReverseDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultReverseWithCallReverseDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultReverseWithError +#define LOCAL_CANONICAL_NAME reverse +#define LOCAL_generic_seq_foo generic_seq_reverse +#define LOCAL_tsc_foo tsc_reverse +#define LOCAL_DeeSeq_AttrFoo Reverse #elif defined(DEFINE_DeeType_SeqCache_RequireReversed) -#define LOCAL_CANONICAL_NAME reversed -#define LOCAL_generic_seq_foo generic_seq_reversed -#define LOCAL_tsc_foo tsc_reversed -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireReversed -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultReversedWithCallAttrReversed -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultReversedWithCallReversedDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultReversedWithCallReversedDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultReversedWithCallReversedDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultReversedWithCopyForeachDefault +#define LOCAL_CANONICAL_NAME reversed +#define LOCAL_generic_seq_foo generic_seq_reversed +#define LOCAL_tsc_foo tsc_reversed +#define LOCAL_DeeSeq_AttrFoo Reversed +#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultReversedWithCopyForeachDefault #elif defined(DEFINE_DeeType_SeqCache_RequireSort) -#define LOCAL_CANONICAL_NAME sort -#define LOCAL_generic_seq_foo generic_seq_sort -#define LOCAL_tsc_foo tsc_sort -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireSort -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultSortWithCallAttrSort -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultSortWithCallSortDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultSortWithCallSortDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultSortWithCallSortDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultSortWithError +#define LOCAL_CANONICAL_NAME sort +#define LOCAL_generic_seq_foo generic_seq_sort +#define LOCAL_tsc_foo tsc_sort +#define LOCAL_DeeSeq_AttrFoo Sort #elif defined(DEFINE_DeeType_SeqCache_RequireSortWithKey) -#define LOCAL_CANONICAL_NAME sort -#define LOCAL_generic_seq_foo generic_seq_sort -#define LOCAL_tsc_foo tsc_sort_with_key -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireSortWithKey -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultSortWithKeyWithCallAttrSort -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultSortWithKeyWithCallSortDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultSortWithKeyWithCallSortDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultSortWithKeyWithCallSortDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultSortWithKeyWithError +#define LOCAL_CANONICAL_NAME sort +#define LOCAL_generic_seq_foo generic_seq_sort +#define LOCAL_tsc_foo tsc_sort_with_key +#define LOCAL_DeeSeq_AttrFoo SortWithKey +#define LOCAL_DeeSeq_AttrBar Sort #elif defined(DEFINE_DeeType_SeqCache_RequireSorted) -#define LOCAL_CANONICAL_NAME sorted -#define LOCAL_generic_seq_foo generic_seq_sorted -#define LOCAL_tsc_foo tsc_sorted -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireSorted -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultSortedWithCallAttrSorted -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultSortedWithCallSortedDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultSortedWithCallSortedDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultSortedWithCallSortedDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultSortedWithCopyForeachDefault +#define LOCAL_CANONICAL_NAME sorted +#define LOCAL_generic_seq_foo generic_seq_sorted +#define LOCAL_tsc_foo tsc_sorted +#define LOCAL_DeeSeq_AttrFoo Sorted +#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultSortedWithCopyForeachDefault #elif defined(DEFINE_DeeType_SeqCache_RequireSortedWithKey) -#define LOCAL_CANONICAL_NAME sorted -#define LOCAL_generic_seq_foo generic_seq_sorted -#define LOCAL_tsc_foo tsc_sorted_with_key -#define LOCAL_DeeType_SeqCache_RequireFoo DeeType_SeqCache_RequireSortedWithKey -#define LOCAL_DeeSeq_DefaultFooWithCallAttrFoo DeeSeq_DefaultSortedWithKeyWithCallAttrSorted -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction DeeSeq_DefaultSortedWithKeyWithCallSortedDataFunction -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod DeeSeq_DefaultSortedWithKeyWithCallSortedDataMethod -#define LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod DeeSeq_DefaultSortedWithKeyWithCallSortedDataKwMethod -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultSortedWithKeyWithCopyForeachDefault +#define LOCAL_CANONICAL_NAME sorted +#define LOCAL_generic_seq_foo generic_seq_sorted +#define LOCAL_tsc_foo tsc_sorted_with_key +#define LOCAL_DeeSeq_AttrFoo SortedWithKey +#define LOCAL_DeeSeq_AttrBar Sorted +#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultSortedWithKeyWithCopyForeachDefault +#elif defined(DEFINE_DeeType_SeqCache_RequireBFind) +#define LOCAL_CANONICAL_NAME bfind +#define LOCAL_generic_seq_foo generic_seq_bfind +#define LOCAL_tsc_foo tsc_bfind +#define LOCAL_DeeSeq_AttrFoo BFind +#elif defined(DEFINE_DeeType_SeqCache_RequireBFindWithKey) +#define LOCAL_CANONICAL_NAME bfind +#define LOCAL_generic_seq_foo generic_seq_bfind +#define LOCAL_tsc_foo tsc_bfind_with_key +#define LOCAL_DeeSeq_AttrFoo BFindWithKey +#define LOCAL_DeeSeq_AttrBar BFind +#elif defined(DEFINE_DeeType_SeqCache_RequireBPosition) +#define LOCAL_CANONICAL_NAME bposition +#define LOCAL_generic_seq_foo generic_seq_bposition +#define LOCAL_tsc_foo tsc_bposition +#define LOCAL_DeeSeq_AttrFoo BPosition +#elif defined(DEFINE_DeeType_SeqCache_RequireBPositionWithKey) +#define LOCAL_CANONICAL_NAME bposition +#define LOCAL_generic_seq_foo generic_seq_bposition +#define LOCAL_tsc_foo tsc_bposition_with_key +#define LOCAL_DeeSeq_AttrFoo BPositionWithKey +#define LOCAL_DeeSeq_AttrBar BPosition +#elif defined(DEFINE_DeeType_SeqCache_RequireBRange) +#define LOCAL_CANONICAL_NAME brange +#define LOCAL_generic_seq_foo generic_seq_brange +#define LOCAL_tsc_foo tsc_brange +#define LOCAL_DeeSeq_AttrFoo BRange +#elif defined(DEFINE_DeeType_SeqCache_RequireBRangeWithKey) +#define LOCAL_CANONICAL_NAME brange +#define LOCAL_generic_seq_foo generic_seq_brange +#define LOCAL_tsc_foo tsc_brange_with_key +#define LOCAL_DeeSeq_AttrFoo BRangeWithKey +#define LOCAL_DeeSeq_AttrBar BRange +#elif defined(DEFINE_DeeType_SeqCache_RequireBLocate) +#define LOCAL_CANONICAL_NAME blocate +#define LOCAL_generic_seq_foo generic_seq_blocate +#define LOCAL_tsc_foo tsc_blocate +#define LOCAL_DeeSeq_AttrFoo BLocate +#elif defined(DEFINE_DeeType_SeqCache_RequireBLocateWithKey) +#define LOCAL_CANONICAL_NAME blocate +#define LOCAL_generic_seq_foo generic_seq_blocate +#define LOCAL_tsc_foo tsc_blocate_with_key +#define LOCAL_DeeSeq_AttrFoo BLocateWithKey +#define LOCAL_DeeSeq_AttrBar BLocate #else /* DEFINE_DeeType_SeqCache_Require... */ #error "Invalid configuration" #endif /* !DEFINE_DeeType_SeqCache_Require... */ +#ifndef LOCAL_DeeSeq_AttrBar +#define LOCAL_DeeSeq_AttrBar LOCAL_DeeSeq_AttrFoo +#endif /* !LOCAL_DeeSeq_AttrBar */ + +#ifndef LOCAL_DeeType_SeqCache_RequireFoo +#define LOCAL_DeeType_SeqCache_RequireFoo_private_uncached PP_CAT3(DeeType_SeqCache_Require, LOCAL_DeeSeq_AttrFoo, _private_uncached) +#define LOCAL_DeeType_SeqCache_RequireFoo_uncached PP_CAT3(DeeType_SeqCache_Require, LOCAL_DeeSeq_AttrFoo, _uncached) +#define LOCAL_DeeType_SeqCache_RequireFoo PP_CAT2(DeeType_SeqCache_Require, LOCAL_DeeSeq_AttrFoo) +#else /* !LOCAL_DeeType_SeqCache_RequireFoo */ +#ifndef LOCAL_DeeType_SeqCache_RequireFoo_private_uncached #define LOCAL_DeeType_SeqCache_RequireFoo_private_uncached PP_CAT2(LOCAL_DeeType_SeqCache_RequireFoo, _private_uncached) -#define LOCAL_DeeType_SeqCache_RequireFoo_uncached PP_CAT2(LOCAL_DeeType_SeqCache_RequireFoo, _uncached) -#define LOCAL_Dee_tsc_foo_t PP_CAT3(Dee_, LOCAL_tsc_foo, _t) +#endif /* !LOCAL_DeeType_SeqCache_RequireFoo_private_uncached */ +#ifndef LOCAL_DeeType_SeqCache_RequireFoo_uncached +#define LOCAL_DeeType_SeqCache_RequireFoo_uncached PP_CAT2(LOCAL_DeeType_SeqCache_RequireFoo, _uncached) +#endif /* !LOCAL_DeeType_SeqCache_RequireFoo_uncached */ +#endif /* LOCAL_DeeType_SeqCache_RequireFoo */ + +#ifndef LOCAL_DeeSeq_DefaultFooWithCallAttrBar +#define LOCAL_DeeSeq_DefaultFooWithCallAttrBar \ + PP_CAT4(DeeSeq_Default, LOCAL_DeeSeq_AttrFoo, WithCallAttr, LOCAL_DeeSeq_AttrBar) +#endif /* !LOCAL_DeeSeq_DefaultFooWithCallAttrBar */ +#ifndef LOCAL_DeeSeq_DefaultFooWithCallBarDataFunction +#define LOCAL_DeeSeq_DefaultFooWithCallBarDataFunction \ + PP_CAT5(DeeSeq_Default, LOCAL_DeeSeq_AttrFoo, WithCall, LOCAL_DeeSeq_AttrBar, DataFunction) +#endif /* !LOCAL_DeeSeq_DefaultFooWithCallBarDataFunction */ +#ifndef LOCAL_DeeSeq_DefaultFooWithCallBarDataMethod +#define LOCAL_DeeSeq_DefaultFooWithCallBarDataMethod \ + PP_CAT5(DeeSeq_Default, LOCAL_DeeSeq_AttrFoo, WithCall, LOCAL_DeeSeq_AttrBar, DataMethod) +#endif /* !LOCAL_DeeSeq_DefaultFooWithCallBarDataMethod */ +#ifndef LOCAL_DeeSeq_DefaultFooWithCallBarDataKwMethod +#define LOCAL_DeeSeq_DefaultFooWithCallBarDataKwMethod \ + PP_CAT5(DeeSeq_Default, LOCAL_DeeSeq_AttrFoo, WithCall, LOCAL_DeeSeq_AttrBar, DataKwMethod) +#endif /* !LOCAL_DeeSeq_DefaultFooWithCallBarDataKwMethod */ +#ifndef LOCAL_DeeSeq_DefaultFooWithError +#define LOCAL_DeeSeq_DefaultFooWithError \ + PP_CAT3(DeeSeq_Default, LOCAL_DeeSeq_AttrFoo, WithError) +#endif /* !LOCAL_DeeSeq_DefaultFooWithError */ + + +#ifndef LOCAL_Dee_tsc_foo_t +#define LOCAL_Dee_tsc_foo_t PP_CAT3(Dee_, LOCAL_tsc_foo, _t) +#endif /* !LOCAL_Dee_tsc_foo_t */ +#ifndef LOCAL_tsc_foo_data +#define LOCAL_tsc_foo_data PP_CAT3(tsc_, LOCAL_CANONICAL_NAME, _data) +#endif /* !LOCAL_tsc_foo_data */ + #define LOCAL_CANONICAL_NAME_LENGTHOF COMPILER_STRLEN(PP_STR(LOCAL_CANONICAL_NAME)) #define LOCAL_CANONICAL_NAME_str PP_CAT2(str_, LOCAL_CANONICAL_NAME) #define LOCAL_CANONICAL_NAME_STR PP_CAT2(STR_, LOCAL_CANONICAL_NAME) #define LOCAL_CANONICAL_NAME_Dee_HashStr PP_CAT2(Dee_HashStr__, LOCAL_CANONICAL_NAME) -#ifndef LOCAL_tsc_foo_data -#define LOCAL_tsc_foo_data PP_CAT3(tsc_, LOCAL_CANONICAL_NAME, _data) -#endif /* !LOCAL_tsc_foo_data */ /* Mutable sequence functions */ @@ -400,8 +377,8 @@ LOCAL_DeeType_SeqCache_RequireFoo_private_uncached(DeeTypeObject *orig_type, Dee return &LOCAL_DeeSeq_DefaultFooWithError; atomic_write(&sc->LOCAL_tsc_foo_data.d_method, attrinfo.ai_value.v_method->m_func); if (attrinfo.ai_value.v_method->m_flag & Dee_TYPE_METHOD_FKWDS) - return &LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod; - return &LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod; + return &LOCAL_DeeSeq_DefaultFooWithCallBarDataKwMethod; + return &LOCAL_DeeSeq_DefaultFooWithCallBarDataMethod; case Dee_ATTRINFO_ATTR: ASSERT(attrinfo.ai_type == Dee_ATTRINFO_ATTR); if ((attrinfo.ai_value.v_attr->ca_flag & (Dee_CLASS_ATTRIBUTE_FMETHOD | Dee_CLASS_ATTRIBUTE_FREADONLY | Dee_CLASS_ATTRIBUTE_FCLASSMEM)) == @@ -416,14 +393,14 @@ LOCAL_DeeType_SeqCache_RequireFoo_private_uncached(DeeTypeObject *orig_type, Dee if likely(callback) { if unlikely(atomic_cmpxch(&sc->LOCAL_tsc_foo_data.d_function, NULL, callback)) Dee_Decref(callback); - return &LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction; + return &LOCAL_DeeSeq_DefaultFooWithCallBarDataFunction; } } break; default: break; } } - return &LOCAL_DeeSeq_DefaultFooWithCallAttrFoo; + return &LOCAL_DeeSeq_DefaultFooWithCallAttrBar; } #ifdef DEFINE_DeeType_SeqCache_RequireFind @@ -474,8 +451,8 @@ LOCAL_DeeType_SeqCache_RequireFoo_private_uncached(DeeTypeObject *orig_type, Dee return &LOCAL_DeeSeq_DefaultFooWithError; atomic_write(&sc->LOCAL_tsc_foo_data.d_method, attrinfo.ai_value.v_method->m_func); if (attrinfo.ai_value.v_method->m_flag & Dee_TYPE_METHOD_FKWDS) - return &LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod; - return &LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod; + return &LOCAL_DeeSeq_DefaultFooWithCallBarDataKwMethod; + return &LOCAL_DeeSeq_DefaultFooWithCallBarDataMethod; case Dee_ATTRINFO_ATTR: ASSERT(attrinfo.ai_type == Dee_ATTRINFO_ATTR); if ((attrinfo.ai_value.v_attr->ca_flag & (Dee_CLASS_ATTRIBUTE_FMETHOD | Dee_CLASS_ATTRIBUTE_FREADONLY | Dee_CLASS_ATTRIBUTE_FCLASSMEM)) == @@ -490,7 +467,7 @@ LOCAL_DeeType_SeqCache_RequireFoo_private_uncached(DeeTypeObject *orig_type, Dee if likely(callback) { if unlikely(atomic_cmpxch(&sc->LOCAL_tsc_foo_data.d_function, NULL, callback)) Dee_Decref(callback); - return &LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction; + return &LOCAL_DeeSeq_DefaultFooWithCallBarDataFunction; } } break; @@ -781,7 +758,80 @@ LOCAL_DeeType_SeqCache_RequireFoo_private_uncached(DeeTypeObject *orig_type, Dee } if (DeeType_HasPrivateOperator(self, OPERATOR_ITER)) return &DeeSeq_DefaultSortedWithKeyWithCopyForeachDefault; /* non-Default would also be OK */ +#elif defined(DEFINE_DeeType_SeqCache_RequireBFind) + { + Dee_tsc_brange_t tsc_brange; + tsc_brange = DeeType_SeqCache_RequireBRange_private_uncached(orig_type, self); + if (tsc_brange != NULL && + tsc_brange != &DeeSeq_DefaultBRangeWithError) { + if (tsc_brange == &DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex) + return &DeeSeq_DefaultBFindWithSizeAndTryGetItemIndex; + return &DeeSeq_DefaultBFindWithTSCBRange; + } + } +#elif defined(DEFINE_DeeType_SeqCache_RequireBFindWithKey) + { + Dee_tsc_brange_with_key_t tsc_brange_with_key; + tsc_brange_with_key = DeeType_SeqCache_RequireBRangeWithKey_private_uncached(orig_type, self); + if (tsc_brange_with_key != NULL && + tsc_brange_with_key != &DeeSeq_DefaultBRangeWithKeyWithError) { + if (tsc_brange_with_key == &DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex) + return &DeeSeq_DefaultBFindWithKeyWithSizeAndTryGetItemIndex; + return &DeeSeq_DefaultBFindWithKeyWithTSCBRangeWithKey; + } + } +#elif defined(DEFINE_DeeType_SeqCache_RequireBPosition) + { + Dee_tsc_brange_t tsc_brange; + tsc_brange = DeeType_SeqCache_RequireBRange_private_uncached(orig_type, self); + if (tsc_brange != NULL && + tsc_brange != &DeeSeq_DefaultBRangeWithError) { + if (tsc_brange == &DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex) + return &DeeSeq_DefaultBPositionWithSizeAndTryGetItemIndex; + return &DeeSeq_DefaultBPositionWithTSCBRange; + } + } +#elif defined(DEFINE_DeeType_SeqCache_RequireBPositionWithKey) + { + Dee_tsc_brange_with_key_t tsc_brange_with_key; + tsc_brange_with_key = DeeType_SeqCache_RequireBRangeWithKey_private_uncached(orig_type, self); + if (tsc_brange_with_key != NULL && + tsc_brange_with_key != &DeeSeq_DefaultBRangeWithKeyWithError) { + if (tsc_brange_with_key == &DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex) + return &DeeSeq_DefaultBPositionWithKeyWithSizeAndTryGetItemIndex; + return &DeeSeq_DefaultBPositionWithKeyWithTSCBRangeWithKey; + } + } +#elif defined(DEFINE_DeeType_SeqCache_RequireBRange) + if (DeeType_HasPrivateOperator(self, OPERATOR_GETITEM) && DeeType_HasOperator(self, OPERATOR_SIZE)) + return &DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex; +#elif defined(DEFINE_DeeType_SeqCache_RequireBRangeWithKey) + if (DeeType_HasPrivateOperator(self, OPERATOR_GETITEM) && DeeType_HasOperator(self, OPERATOR_SIZE)) + return &DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex; +#elif defined(DEFINE_DeeType_SeqCache_RequireBLocate) + { + Dee_tsc_bfind_t tsc_bfind; + tsc_bfind = DeeType_SeqCache_RequireBFind_private_uncached(orig_type, self); + if (tsc_bfind != NULL && + tsc_bfind != &DeeSeq_DefaultBFindWithError) { + if (tsc_bfind == &DeeSeq_DefaultBFindWithSizeAndTryGetItemIndex) + return &DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex; + return &DeeSeq_DefaultBLocateWithTSCBFindAndGetItemIndex; + } + } +#elif defined(DEFINE_DeeType_SeqCache_RequireBLocateWithKey) + { + Dee_tsc_bfind_with_key_t tsc_bfind_with_key; + tsc_bfind_with_key = DeeType_SeqCache_RequireBFindWithKey_private_uncached(orig_type, self); + if (tsc_bfind_with_key != NULL && + tsc_bfind_with_key != &DeeSeq_DefaultBFindWithKeyWithError) { + if (tsc_bfind_with_key == &DeeSeq_DefaultBFindWithKeyWithSizeAndTryGetItemIndex) + return &DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex; + return &DeeSeq_DefaultBLocateWithKeyWithTSCBFindWithKeyAndGetItemIndex; + } + } #endif /* ... */ + return NULL; } @@ -817,17 +867,15 @@ LOCAL_DeeType_SeqCache_RequireFoo(DeeTypeObject *__restrict self) { } -#undef LOCAL_CANONICAL_NAME -#undef LOCAL_generic_seq_foo -#undef LOCAL_tsc_foo -#undef LOCAL_DeeType_SeqCache_RequireFoo -#undef LOCAL_DeeSeq_DefaultFooWithCallAttrFoo -#undef LOCAL_DeeSeq_DefaultFooWithCallFooDataFunction -#undef LOCAL_DeeSeq_DefaultFooWithCallFooDataMethod -#undef LOCAL_DeeSeq_DefaultFooWithCallFooDataKwMethod -#undef LOCAL_DeeSeq_DefaultFooWithError +#undef LOCAL_DeeSeq_AttrBar #undef LOCAL_DeeType_SeqCache_RequireFoo_private_uncached #undef LOCAL_DeeType_SeqCache_RequireFoo_uncached +#undef LOCAL_DeeType_SeqCache_RequireFoo +#undef LOCAL_DeeSeq_DefaultFooWithCallAttrBar +#undef LOCAL_DeeSeq_DefaultFooWithCallBarDataFunction +#undef LOCAL_DeeSeq_DefaultFooWithCallBarDataMethod +#undef LOCAL_DeeSeq_DefaultFooWithCallBarDataKwMethod +#undef LOCAL_DeeSeq_DefaultFooWithError #undef LOCAL_Dee_tsc_foo_t #undef LOCAL_tsc_foo_data #undef LOCAL_CANONICAL_NAME_LENGTHOF @@ -835,6 +883,13 @@ LOCAL_DeeType_SeqCache_RequireFoo(DeeTypeObject *__restrict self) { #undef LOCAL_CANONICAL_NAME_STR #undef LOCAL_CANONICAL_NAME_Dee_HashStr + +#undef LOCAL_CANONICAL_NAME +#undef LOCAL_generic_seq_foo +#undef LOCAL_tsc_foo +#undef LOCAL_DeeSeq_AttrFoo +#undef LOCAL_DeeSeq_AttrBar + DECL_END #undef DEFINE_DeeType_SeqCache_RequireFind @@ -865,3 +920,11 @@ DECL_END #undef DEFINE_DeeType_SeqCache_RequireSortWithKey #undef DEFINE_DeeType_SeqCache_RequireSorted #undef DEFINE_DeeType_SeqCache_RequireSortedWithKey +#undef DEFINE_DeeType_SeqCache_RequireBFind +#undef DEFINE_DeeType_SeqCache_RequireBFindWithKey +#undef DEFINE_DeeType_SeqCache_RequireBPosition +#undef DEFINE_DeeType_SeqCache_RequireBPositionWithKey +#undef DEFINE_DeeType_SeqCache_RequireBRange +#undef DEFINE_DeeType_SeqCache_RequireBRangeWithKey +#undef DEFINE_DeeType_SeqCache_RequireBLocate +#undef DEFINE_DeeType_SeqCache_RequireBLocateWithKey diff --git a/src/deemon/objects/seq/default-api-methods.c b/src/deemon/objects/seq/default-api-methods.c index 3d25ca172..89f80e6ad 100644 --- a/src/deemon/objects/seq/default-api-methods.c +++ b/src/deemon/objects/seq/default-api-methods.c @@ -101,35 +101,51 @@ PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_sort_t DCALL DeeType_SeqCache_RequireSor PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_sort_with_key_t DCALL DeeType_SeqCache_RequireSortWithKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_sorted_t DCALL DeeType_SeqCache_RequireSorted_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_sorted_with_key_t DCALL DeeType_SeqCache_RequireSortedWithKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); - -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_find_t DCALL DeeType_SeqCache_RequireFind_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_find_with_key_t DCALL DeeType_SeqCache_RequireFindWithKey_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_rfind_t DCALL DeeType_SeqCache_RequireRFind_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_rfind_with_key_t DCALL DeeType_SeqCache_RequireRFindWithKey_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_erase_t DCALL DeeType_SeqCache_RequireErase_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_insert_t DCALL DeeType_SeqCache_RequireInsert_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_insertall_t DCALL DeeType_SeqCache_RequireInsertAll_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_pushfront_t DCALL DeeType_SeqCache_RequirePushFront_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_append_t DCALL DeeType_SeqCache_RequireAppend_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_extend_t DCALL DeeType_SeqCache_RequireExtend_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_xchitem_index_t DCALL DeeType_SeqCache_RequireXchItemIndex_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_clear_t DCALL DeeType_SeqCache_RequireClear_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_pop_t DCALL DeeType_SeqCache_RequirePop_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_remove_t DCALL DeeType_SeqCache_RequireRemove_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_remove_with_key_t DCALL DeeType_SeqCache_RequireRemoveWithKey_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_rremove_t DCALL DeeType_SeqCache_RequireRRemove_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_rremove_with_key_t DCALL DeeType_SeqCache_RequireRRemoveWithKey_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_removeall_t DCALL DeeType_SeqCache_RequireRemoveAll_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_removeall_with_key_t DCALL DeeType_SeqCache_RequireRemoveAllWithKey_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_removeif_t DCALL DeeType_SeqCache_RequireRemoveIf_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_resize_t DCALL DeeType_SeqCache_RequireResize_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_fill_t DCALL DeeType_SeqCache_RequireFill_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_reverse_t DCALL DeeType_SeqCache_RequireReverse_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_reversed_t DCALL DeeType_SeqCache_RequireReversed_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_sort_t DCALL DeeType_SeqCache_RequireSort_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_sort_with_key_t DCALL DeeType_SeqCache_RequireSortWithKey_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_sorted_t DCALL DeeType_SeqCache_RequireSorted_uncached(DeeTypeObject *__restrict self); -PRIVATE WUNUSED NONNULL((1)) Dee_tsc_sorted_with_key_t DCALL DeeType_SeqCache_RequireSortedWithKey_uncached(DeeTypeObject *__restrict self); +PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_bfind_t DCALL DeeType_SeqCache_RequireBFind_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); +PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_bfind_with_key_t DCALL DeeType_SeqCache_RequireBFindWithKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); +PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_bposition_t DCALL DeeType_SeqCache_RequireBPosition_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); +PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_bposition_with_key_t DCALL DeeType_SeqCache_RequireBPositionWithKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); +PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_brange_t DCALL DeeType_SeqCache_RequireBRange_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); +PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_brange_with_key_t DCALL DeeType_SeqCache_RequireBRangeWithKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); +PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_blocate_t DCALL DeeType_SeqCache_RequireBLocate_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); +PRIVATE WUNUSED NONNULL((1, 2)) Dee_tsc_blocate_with_key_t DCALL DeeType_SeqCache_RequireBLocateWithKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); + +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_find_t DCALL DeeType_SeqCache_RequireFind_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_find_with_key_t DCALL DeeType_SeqCache_RequireFindWithKey_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_rfind_t DCALL DeeType_SeqCache_RequireRFind_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_rfind_with_key_t DCALL DeeType_SeqCache_RequireRFindWithKey_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_erase_t DCALL DeeType_SeqCache_RequireErase_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_insert_t DCALL DeeType_SeqCache_RequireInsert_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_insertall_t DCALL DeeType_SeqCache_RequireInsertAll_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_pushfront_t DCALL DeeType_SeqCache_RequirePushFront_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_append_t DCALL DeeType_SeqCache_RequireAppend_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_extend_t DCALL DeeType_SeqCache_RequireExtend_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_xchitem_index_t DCALL DeeType_SeqCache_RequireXchItemIndex_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_clear_t DCALL DeeType_SeqCache_RequireClear_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_pop_t DCALL DeeType_SeqCache_RequirePop_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_remove_t DCALL DeeType_SeqCache_RequireRemove_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_remove_with_key_t DCALL DeeType_SeqCache_RequireRemoveWithKey_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_rremove_t DCALL DeeType_SeqCache_RequireRRemove_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_rremove_with_key_t DCALL DeeType_SeqCache_RequireRRemoveWithKey_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_removeall_t DCALL DeeType_SeqCache_RequireRemoveAll_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_removeall_with_key_t DCALL DeeType_SeqCache_RequireRemoveAllWithKey_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_removeif_t DCALL DeeType_SeqCache_RequireRemoveIf_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_resize_t DCALL DeeType_SeqCache_RequireResize_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_fill_t DCALL DeeType_SeqCache_RequireFill_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_reverse_t DCALL DeeType_SeqCache_RequireReverse_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_reversed_t DCALL DeeType_SeqCache_RequireReversed_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_sort_t DCALL DeeType_SeqCache_RequireSort_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_sort_with_key_t DCALL DeeType_SeqCache_RequireSortWithKey_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_sorted_t DCALL DeeType_SeqCache_RequireSorted_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_sorted_with_key_t DCALL DeeType_SeqCache_RequireSortedWithKey_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_bfind_t DCALL DeeType_SeqCache_RequireBFind_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_bfind_with_key_t DCALL DeeType_SeqCache_RequireBFindWithKey_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_bposition_t DCALL DeeType_SeqCache_RequireBPosition_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_bposition_with_key_t DCALL DeeType_SeqCache_RequireBPositionWithKey_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_brange_t DCALL DeeType_SeqCache_RequireBRange_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_brange_with_key_t DCALL DeeType_SeqCache_RequireBRangeWithKey_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_blocate_t DCALL DeeType_SeqCache_RequireBLocate_uncached(DeeTypeObject *__restrict self); +PRIVATE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_blocate_with_key_t DCALL DeeType_SeqCache_RequireBLocateWithKey_uncached(DeeTypeObject *__restrict self); /* Mutable sequence functions */ @@ -2494,6 +2510,34 @@ DeeSeq_DefaultSortedWithKeyWithCopyForeachDefault(DeeObject *self, size_t start, +/************************************************************************/ +/* bfind() */ +/************************************************************************/ + +INTERN WUNUSED NONNULL((1, 2)) size_t DCALL +DeeSeq_DefaultBFindWithTSCBRange(DeeObject *self, DeeObject *item, + size_t start, size_t end) { + size_t result_range[2]; + if unlikely(new_DeeSeq_BRange(self, item, start, end, result_range)) + goto err; + if (result_range[0] == result_range[1]) + return (size_t)-1; /* Not found */ + if unlikely(result_range[0] == (size_t)Dee_COMPARE_ERR || + result_range[0] == (size_t)-1) + goto err_overflow; + return result_range[0]; +err_overflow: + err_integer_overflow_i(sizeof(size_t) * 8, true); +err: + return (size_t)Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2)) size_t DCALL +DeeSeq_DefaultBFindWithError(DeeObject *self, DeeObject *item, + size_t start, size_t end) { + err_seq_not_mutablef(self, "bfind(%r, %" PRFuSIZ ", %" PRFuSIZ ")", item, start, end); + return (size_t)Dee_COMPARE_ERR; +} @@ -2501,57 +2545,218 @@ DeeSeq_DefaultSortedWithKeyWithCopyForeachDefault(DeeObject *self, size_t start, /************************************************************************/ -/* Deemon user-code wrappers */ +/* bfind() (with key) */ /************************************************************************/ -/* Generic sequence mutable function pointers. */ +INTERN WUNUSED NONNULL((1, 2, 5)) size_t DCALL +DeeSeq_DefaultBFindWithKeyWithTSCBRangeWithKey(DeeObject *self, DeeObject *item, + size_t start, size_t end, DeeObject *key) { + size_t result_range[2]; + if unlikely(new_DeeSeq_BRangeWithKey(self, item, start, end, key, result_range)) + goto err; + if (result_range[0] == result_range[1]) + return (size_t)-1; /* Not found */ + if unlikely(result_range[0] == (size_t)Dee_COMPARE_ERR || + result_range[0] == (size_t)-1) + goto err_overflow; + return result_range[0]; +err_overflow: + err_integer_overflow_i(sizeof(size_t) * 8, true); +err: + return (size_t)Dee_COMPARE_ERR; +} -INTERN WUNUSED NONNULL((1)) DREF DeeObject *DCALL -generic_seq_find(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - DeeObject *item, *key = Dee_None; - size_t result, start = 0, end = (size_t)-1; - if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, - "o|" UNPuSIZ UNPuSIZ "o:find", - &item, &start, &end, &key)) +INTERN WUNUSED NONNULL((1, 2, 5)) size_t DCALL +DeeSeq_DefaultBFindWithKeyWithError(DeeObject *self, DeeObject *item, + size_t start, size_t end, DeeObject *key) { + err_seq_not_mutablef(self, "bfind(%r, %" PRFuSIZ ", %" PRFuSIZ ", %r)", item, start, end, key); + return (size_t)Dee_COMPARE_ERR; +} + + + + + + +/************************************************************************/ +/* bposition() */ +/************************************************************************/ + +INTERN WUNUSED NONNULL((1, 2)) size_t DCALL +DeeSeq_DefaultBPositionWithTSCBRange(DeeObject *self, DeeObject *item, + size_t start, size_t end) { + size_t result_range[2]; + if unlikely(new_DeeSeq_BRange(self, item, start, end, result_range)) goto err; - result = !DeeNone_Check(key) - ? new_DeeSeqFindWithKey(self, item, start, end, key) - : new_DeeSeqFind(self, item, start, end); - if unlikely(result == (size_t)Dee_COMPARE_ERR) + if unlikely(result_range[0] == (size_t)Dee_COMPARE_ERR || + result_range[0] == (size_t)-1) + goto err_overflow; + return result_range[0]; +err_overflow: + err_integer_overflow_i(sizeof(size_t) * 8, true); +err: + return (size_t)Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2)) size_t DCALL +DeeSeq_DefaultBPositionWithError(DeeObject *self, DeeObject *item, + size_t start, size_t end) { + err_seq_not_mutablef(self, "bposition(%r, %" PRFuSIZ ", %" PRFuSIZ ")", item, start, end); + return (size_t)Dee_COMPARE_ERR; +} + + + + + + +/************************************************************************/ +/* bposition() (with key) */ +/************************************************************************/ + +INTERN WUNUSED NONNULL((1, 2, 5)) size_t DCALL +DeeSeq_DefaultBPositionWithKeyWithTSCBRangeWithKey(DeeObject *self, DeeObject *item, + size_t start, size_t end, DeeObject *key) { + size_t result_range[2]; + if unlikely(new_DeeSeq_BRangeWithKey(self, item, start, end, key, result_range)) goto err; - if unlikely(result == (size_t)-1) - return_reference_(DeeInt_MinusOne); - return DeeInt_NewSize(result); + if unlikely(result_range[0] == (size_t)Dee_COMPARE_ERR || + result_range[0] == (size_t)-1) + goto err_overflow; + return result_range[0]; +err_overflow: + err_integer_overflow_i(sizeof(size_t) * 8, true); err: - return NULL; + return (size_t)Dee_COMPARE_ERR; } -INTERN WUNUSED NONNULL((1)) DREF DeeObject *DCALL -generic_seq_rfind(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - DeeObject *item, *key = Dee_None; - size_t result, start = 0, end = (size_t)-1; - if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, - "o|" UNPuSIZ UNPuSIZ "o:rfind", - &item, &start, &end, &key)) +INTERN WUNUSED NONNULL((1, 2, 5)) size_t DCALL +DeeSeq_DefaultBPositionWithKeyWithError(DeeObject *self, DeeObject *item, + size_t start, size_t end, DeeObject *key) { + err_seq_not_mutablef(self, "bposition(%r, %" PRFuSIZ ", %" PRFuSIZ ", %r)", item, start, end, key); + return (size_t)Dee_COMPARE_ERR; +} + + + + + + +/************************************************************************/ +/* brange() */ +/************************************************************************/ + +INTERN WUNUSED NONNULL((1, 2, 5)) int DCALL +DeeSeq_DefaultBRangeWithError(DeeObject *self, DeeObject *item, + size_t start, size_t end, + size_t result_range[2]) { + (void)result_range; + return err_seq_not_mutablef(self, "brange(%r, %" PRFuSIZ ", %" PRFuSIZ ")", item, start, end); +} + + + + + + +/************************************************************************/ +/* brange() (with key) */ +/************************************************************************/ + +INTERN WUNUSED NONNULL((1, 2, 5, 6)) int DCALL +DeeSeq_DefaultBRangeWithKeyWithError(DeeObject *self, DeeObject *item, + size_t start, size_t end, DeeObject *key, + size_t result_range[2]) { + (void)result_range; + return err_seq_not_mutablef(self, "brange(%r, %" PRFuSIZ ", %" PRFuSIZ ", %r)", item, start, end, key); +} + + + + + + +/************************************************************************/ +/* blocate() */ +/************************************************************************/ + +INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL +DeeSeq_DefaultBLocateWithTSCBFindAndGetItemIndex(DeeObject *self, DeeObject *item, + size_t start, size_t end) { + size_t index = new_DeeSeq_BFind(self, item, start, end); + if unlikely(index == (size_t)Dee_COMPARE_ERR) goto err; - result = !DeeNone_Check(key) - ? new_DeeSeqRFindWithKey(self, item, start, end, key) - : new_DeeSeqRFind(self, item, start, end); - if unlikely(result == (size_t)Dee_COMPARE_ERR) + if unlikely(index == (size_t)-1) + goto err_not_found; + return (*Dee_TYPE(self)->tp_seq->tp_getitem_index)(self, index); +err_not_found: + err_item_not_found(self, item); +err: + return NULL; +} + +INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL +DeeSeq_DefaultBLocateWithError(DeeObject *self, DeeObject *item, + size_t start, size_t end) { + err_seq_not_mutablef(self, "blocate(%r, %" PRFuSIZ ", %" PRFuSIZ ")", item, start, end); + return NULL; +} + + + + + + +/************************************************************************/ +/* blocate() (with key) */ +/************************************************************************/ + +INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL +DeeSeq_DefaultBLocateWithKeyWithTSCBFindWithKeyAndGetItemIndex(DeeObject *self, DeeObject *item, + size_t start, size_t end, DeeObject *key) { + size_t index = new_DeeSeq_BFindWithKey(self, item, start, end, key); + if unlikely(index == (size_t)Dee_COMPARE_ERR) goto err; - if unlikely(result == (size_t)-1) - return_reference_(DeeInt_MinusOne); - return DeeInt_NewSize(result); + if unlikely(index == (size_t)-1) + goto err_not_found; + return (*Dee_TYPE(self)->tp_seq->tp_getitem_index)(self, index); +err_not_found: + err_item_not_found(self, item); err: return NULL; } +INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL +DeeSeq_DefaultBLocateWithKeyWithError(DeeObject *self, DeeObject *item, + size_t start, size_t end, DeeObject *key) { + err_seq_not_mutablef(self, "blocate(%r, %" PRFuSIZ ", %" PRFuSIZ ", %r)", item, start, end, key); + return NULL; +} + + + + + + + + + + + + + +/************************************************************************/ +/* Deemon user-code wrappers */ +/************************************************************************/ + +/* Generic sequence mutable function pointers. */ + INTERN WUNUSED NONNULL((1)) DREF DeeObject *DCALL -generic_seq_index(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { +generic_seq_find(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { DeeObject *item, *key = Dee_None; size_t result, start = 0, end = (size_t)-1; if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, - "o|" UNPuSIZ UNPuSIZ "o:index", + "o|" UNPuSIZ UNPuSIZ "o:find", &item, &start, &end, &key)) goto err; result = !DeeNone_Check(key) @@ -2560,20 +2765,18 @@ generic_seq_index(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObjec if unlikely(result == (size_t)Dee_COMPARE_ERR) goto err; if unlikely(result == (size_t)-1) - goto err_no_item; + return_reference_(DeeInt_MinusOne); return DeeInt_NewSize(result); -err_no_item: - err_item_not_found(self, item); err: return NULL; } INTERN WUNUSED NONNULL((1)) DREF DeeObject *DCALL -generic_seq_rindex(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { +generic_seq_rfind(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { DeeObject *item, *key = Dee_None; size_t result, start = 0, end = (size_t)-1; if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, - "o|" UNPuSIZ UNPuSIZ "o:rindex", + "o|" UNPuSIZ UNPuSIZ "o:rfind", &item, &start, &end, &key)) goto err; result = !DeeNone_Check(key) @@ -2582,10 +2785,8 @@ generic_seq_rindex(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObje if unlikely(result == (size_t)Dee_COMPARE_ERR) goto err; if unlikely(result == (size_t)-1) - goto err_no_item; + return_reference_(DeeInt_MinusOne); return DeeInt_NewSize(result); -err_no_item: - err_item_not_found(self, item); err: return NULL; } @@ -2883,6 +3084,78 @@ generic_seq_sorted(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObje return NULL; } +INTERN WUNUSED NONNULL((1)) DREF DeeObject *DCALL +generic_seq_bfind(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { + DeeObject *item, *key = Dee_None; + size_t result, start = 0, end = (size_t)-1; + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, + "o|" UNPuSIZ UNPuSIZ "o:bfind", + &item, &start, &end, &key)) + goto err; + result = !DeeNone_Check(key) + ? new_DeeSeq_BFindWithKey(self, item, start, end, key) + : new_DeeSeq_BFind(self, item, start, end); + if unlikely(result == (size_t)Dee_COMPARE_ERR) + goto err; + if unlikely(result == (size_t)-1) + return_none; + return DeeInt_NewSize(result); +err: + return NULL; +} + +INTERN WUNUSED NONNULL((1)) DREF DeeObject *DCALL +generic_seq_bposition(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { + DeeObject *item, *key = Dee_None; + size_t result, start = 0, end = (size_t)-1; + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, + "o|" UNPuSIZ UNPuSIZ "o:bposition", + &item, &start, &end, &key)) + goto err; + result = !DeeNone_Check(key) + ? new_DeeSeq_BPositionWithKey(self, item, start, end, key) + : new_DeeSeq_BPosition(self, item, start, end); + if unlikely(result == (size_t)Dee_COMPARE_ERR) + goto err; + return DeeInt_NewSize(result); +err: + return NULL; +} + +INTERN WUNUSED NONNULL((1)) DREF DeeObject *DCALL +generic_seq_brange(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { + DeeObject *item, *key = Dee_None; + size_t start = 0, end = (size_t)-1, result_range[2]; + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, + "o|" UNPuSIZ UNPuSIZ "o:brange", + &item, &start, &end, &key)) + goto err; + if (!DeeNone_Check(key) + ? new_DeeSeq_BRangeWithKey(self, item, start, end, key, result_range) + : new_DeeSeq_BRange(self, item, start, end, result_range)) + goto err; + return DeeTuple_Newf(PCKuSIZ PCKuSIZ, result_range[0], result_range[1]); +err: + return NULL; +} + +INTERN WUNUSED NONNULL((1)) DREF DeeObject *DCALL +generic_seq_blocate(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { + DeeObject *item, *key = Dee_None; + size_t start = 0, end = (size_t)-1; + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, + "o|" UNPuSIZ UNPuSIZ "o:blocate", + &item, &start, &end, &key)) + goto err; + return !DeeNone_Check(key) + ? new_DeeSeq_BLocateWithKey(self, item, start, end, key) + : new_DeeSeq_BLocate(self, item, start, end); +err: + return NULL; +} + + + #if 0 PRIVATE struct type_method tpconst generic_seq_methods[] = { TYPE_KWMETHOD(STR_find, &generic_seq_find, "(item,start=!0,end=!-1,key:?DCallable=!N)->?Dint"), @@ -2910,6 +3183,10 @@ PRIVATE struct type_method tpconst generic_seq_methods[] = { TYPE_KWMETHOD(STR_fill, &generic_seq_fill, "(start=!0,end=!-1,filler=!N)"), TYPE_KWMETHOD(STR_reverse, &generic_seq_reverse, "(start=!0,end=!-1)"), TYPE_KWMETHOD(STR_sort, &generic_seq_sort, "(start=!0,end=!-1,key:?DCallable=!N)"), + TYPE_KWMETHOD(STR_bfind, &generic_seq_bfind, "(item,start=!0,end=!-1,key:?DCallable=!N)->?Dint"), + TYPE_KWMETHOD(STR_bposition, &generic_seq_bposition, "(item,start=!0,end=!-1,key:?DCallable=!N)->?Dint"), + TYPE_KWMETHOD(STR_brange, &generic_seq_brange, "(item,start=!0,end=!-1,key:?DCallable=!N)->?X2?Dint?Dint"), + TYPE_KWMETHOD(STR_blocate, &generic_seq_blocate, "(item,start=!0,end=!-1,key:?DCallable=!N)->"), TYPE_METHOD_END }; #endif @@ -2974,6 +3251,22 @@ DECL_END #include "default-api-methods-require-impl.c.inl" #define DEFINE_DeeType_SeqCache_RequireSortedWithKey #include "default-api-methods-require-impl.c.inl" +#define DEFINE_DeeType_SeqCache_RequireBFind +#include "default-api-methods-require-impl.c.inl" +#define DEFINE_DeeType_SeqCache_RequireBFindWithKey +#include "default-api-methods-require-impl.c.inl" +#define DEFINE_DeeType_SeqCache_RequireBPosition +#include "default-api-methods-require-impl.c.inl" +#define DEFINE_DeeType_SeqCache_RequireBPositionWithKey +#include "default-api-methods-require-impl.c.inl" +#define DEFINE_DeeType_SeqCache_RequireBRange +#include "default-api-methods-require-impl.c.inl" +#define DEFINE_DeeType_SeqCache_RequireBRangeWithKey +#include "default-api-methods-require-impl.c.inl" +#define DEFINE_DeeType_SeqCache_RequireBLocate +#include "default-api-methods-require-impl.c.inl" +#define DEFINE_DeeType_SeqCache_RequireBLocateWithKey +#include "default-api-methods-require-impl.c.inl" #endif /* !__INTELLISENSE__ */ @@ -2989,4 +3282,25 @@ DECL_END #include "default-api-methods-attrproxy-impl.c.inl" #endif /* !__INTELLISENSE__ */ + +/* Define implementations of bsearch functions */ +#ifndef __INTELLISENSE__ +#define DEFINE_DeeSeq_DefaultBFindWithSizeAndTryGetItemIndex +#include "default-api-methods-bsearch-impl.c.inl" +#define DEFINE_DeeSeq_DefaultBFindWithKeyWithSizeAndTryGetItemIndex +#include "default-api-methods-bsearch-impl.c.inl" +#define DEFINE_DeeSeq_DefaultBPositionWithSizeAndTryGetItemIndex +#include "default-api-methods-bsearch-impl.c.inl" +#define DEFINE_DeeSeq_DefaultBPositionWithKeyWithSizeAndTryGetItemIndex +#include "default-api-methods-bsearch-impl.c.inl" +#define DEFINE_DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex +#include "default-api-methods-bsearch-impl.c.inl" +#define DEFINE_DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex +#include "default-api-methods-bsearch-impl.c.inl" +#define DEFINE_DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex +#include "default-api-methods-bsearch-impl.c.inl" +#define DEFINE_DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex +#include "default-api-methods-bsearch-impl.c.inl" +#endif /* !__INTELLISENSE__ */ + #endif /* !GUARD_DEEMON_OBJECTS_SEQ_DEFAULT_API_METHODS_C */ diff --git a/src/deemon/objects/seq/default-api.c b/src/deemon/objects/seq/default-api.c index c33ba0e6e..21b52bdf5 100644 --- a/src/deemon/objects/seq/default-api.c +++ b/src/deemon/objects/seq/default-api.c @@ -135,8 +135,8 @@ Dee_type_seq_cache_destroy(struct Dee_type_seq_cache *__restrict self) { Dee_tsc_uslot_fini_function(&self->tsc_append_data); if (self->tsc_extend == &DeeSeq_DefaultExtendWithCallExtendDataFunction) Dee_tsc_uslot_fini_function(&self->tsc_extend_data); - if (self->tsc_xchitem_index == &DeeSeq_DefaultXchItemIndexWithCallXchItemIndexDataFunction) - Dee_tsc_uslot_fini_function(&self->tsc_xchitem_index_data); + if (self->tsc_xchitem_index == &DeeSeq_DefaultXchItemIndexWithCallXchItemDataFunction) + Dee_tsc_uslot_fini_function(&self->tsc_xchitem_data); if (self->tsc_clear == &DeeSeq_DefaultClearWithCallClearDataFunction) Dee_tsc_uslot_fini_function(&self->tsc_clear_data); if (self->tsc_pop == &DeeSeq_DefaultPopWithCallPopDataFunction) diff --git a/src/deemon/objects/seq/default-api.h b/src/deemon/objects/seq/default-api.h index e49bd88b6..a73a7eb3a 100644 --- a/src/deemon/objects/seq/default-api.h +++ b/src/deemon/objects/seq/default-api.h @@ -82,6 +82,14 @@ typedef WUNUSED_T NONNULL_T((1)) int (DCALL *Dee_tsc_sort_t)(DeeObject *self, si typedef WUNUSED_T NONNULL_T((1, 4)) int (DCALL *Dee_tsc_sort_with_key_t)(DeeObject *self, size_t start, size_t end, DeeObject *key); typedef WUNUSED_T NONNULL_T((1)) DREF DeeObject *(DCALL *Dee_tsc_sorted_t)(DeeObject *self, size_t start, size_t end); typedef WUNUSED_T NONNULL_T((1, 4)) DREF DeeObject *(DCALL *Dee_tsc_sorted_with_key_t)(DeeObject *self, size_t start, size_t end, DeeObject *key); +typedef WUNUSED_T NONNULL_T((1, 2)) size_t (DCALL *Dee_tsc_bfind_t)(DeeObject *self, DeeObject *item, size_t start, size_t end); /* @return: (size_t)-1: Not found; @return (size_t)Dee_COMPARE_ERR: Error */ +typedef WUNUSED_T NONNULL_T((1, 2, 5)) size_t (DCALL *Dee_tsc_bfind_with_key_t)(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); /* @return: (size_t)-1: Not found; @return (size_t)Dee_COMPARE_ERR: Error */ +typedef WUNUSED_T NONNULL_T((1, 2)) size_t (DCALL *Dee_tsc_bposition_t)(DeeObject *self, DeeObject *item, size_t start, size_t end); /* @return: (size_t)Dee_COMPARE_ERR: Error */ +typedef WUNUSED_T NONNULL_T((1, 2, 5)) size_t (DCALL *Dee_tsc_bposition_with_key_t)(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); /* @return: (size_t)Dee_COMPARE_ERR: Error */ +typedef WUNUSED_T NONNULL_T((1, 2, 5)) int (DCALL *Dee_tsc_brange_t)(DeeObject *self, DeeObject *item, size_t start, size_t end, size_t result_range[2]); +typedef WUNUSED_T NONNULL_T((1, 2, 5, 6)) int (DCALL *Dee_tsc_brange_with_key_t)(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key, size_t result_range[2]); +typedef WUNUSED_T NONNULL_T((1, 2)) DREF DeeObject *(DCALL *Dee_tsc_blocate_t)(DeeObject *self, DeeObject *item, size_t start, size_t end); +typedef WUNUSED_T NONNULL_T((1, 2, 5)) DREF DeeObject *(DCALL *Dee_tsc_blocate_with_key_t)(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); union Dee_tsc_uslot { DREF DeeObject *d_function; /* [1..1][valid_if(tsc_erase == ...)] Thiscall function. */ @@ -132,7 +140,7 @@ struct Dee_type_seq_cache { Dee_tsc_extend_t tsc_extend; union Dee_tsc_uslot tsc_extend_data; Dee_tsc_xchitem_index_t tsc_xchitem_index; - union Dee_tsc_uslot tsc_xchitem_index_data; + union Dee_tsc_uslot tsc_xchitem_data; Dee_tsc_clear_t tsc_clear; union Dee_tsc_uslot tsc_clear_data; Dee_tsc_pop_t tsc_pop; @@ -162,7 +170,18 @@ struct Dee_type_seq_cache { Dee_tsc_sorted_t tsc_sorted; Dee_tsc_sorted_with_key_t tsc_sorted_with_key; union Dee_tsc_uslot tsc_sorted_data; - + Dee_tsc_bfind_t tsc_bfind; + Dee_tsc_bfind_with_key_t tsc_bfind_with_key; + union Dee_tsc_uslot tsc_bfind_data; + Dee_tsc_bposition_t tsc_bposition; + Dee_tsc_bposition_with_key_t tsc_bposition_with_key; + union Dee_tsc_uslot tsc_bposition_data; + Dee_tsc_brange_t tsc_brange; + Dee_tsc_brange_with_key_t tsc_brange_with_key; + union Dee_tsc_uslot tsc_brange_data; + Dee_tsc_blocate_t tsc_blocate; + Dee_tsc_blocate_with_key_t tsc_blocate_with_key; + union Dee_tsc_uslot tsc_blocate_data; /************************************************************************/ /* For `deemon.Set' (only allocated if derived from "Set") */ @@ -224,6 +243,14 @@ INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_sort_t DCALL DeeType_SeqCach INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_sort_with_key_t DCALL DeeType_SeqCache_RequireSortWithKey(DeeTypeObject *__restrict self); INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_sorted_t DCALL DeeType_SeqCache_RequireSorted(DeeTypeObject *__restrict self); INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_sorted_with_key_t DCALL DeeType_SeqCache_RequireSortedWithKey(DeeTypeObject *__restrict self); +INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_bfind_t DCALL DeeType_SeqCache_RequireBFind(DeeTypeObject *__restrict self); +INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_bfind_with_key_t DCALL DeeType_SeqCache_RequireBFindWithKey(DeeTypeObject *__restrict self); +INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_bposition_t DCALL DeeType_SeqCache_RequireBPosition(DeeTypeObject *__restrict self); +INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_bposition_with_key_t DCALL DeeType_SeqCache_RequireBPositionWithKey(DeeTypeObject *__restrict self); +INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_brange_t DCALL DeeType_SeqCache_RequireBRange(DeeTypeObject *__restrict self); +INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_brange_with_key_t DCALL DeeType_SeqCache_RequireBRangeWithKey(DeeTypeObject *__restrict self); +INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_blocate_t DCALL DeeType_SeqCache_RequireBLocate(DeeTypeObject *__restrict self); +INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_blocate_with_key_t DCALL DeeType_SeqCache_RequireBLocateWithKey(DeeTypeObject *__restrict self); /* Same as `DeeObject_EnumerateIndex()', but also works for treats `self' as `self as Sequence' */ #define DeeSeq_EnumerateIndex(self, proc, arg, start, end) \ @@ -239,75 +266,47 @@ INTDEF ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_tsc_sorted_with_key_t DCALL DeeT #define DeeSeq_DelLast(self) (*DeeType_SeqCache_RequireDelLast(Dee_TYPE(self)))(self) #define DeeSeq_SetLast(self, v) (*DeeType_SeqCache_RequireSetLast(Dee_TYPE(self)))(self, v) -#define DeeSeq_NonEmpty(self) \ - (*DeeType_SeqCache_RequireNonEmpty(Dee_TYPE(self)))(self) -#define DeeSeq_Find(self, item, start, end) \ - (*DeeType_SeqCache_RequireFind(Dee_TYPE(self)))(self, item, start, end) -#define DeeSeq_RFind(self, item, start, end) \ - (*DeeType_SeqCache_RequireRFind(Dee_TYPE(self)))(self, item, start, end) -#define DeeSeq_FindWithKey(self, item, start, end, key) \ - (*DeeType_SeqCache_RequireFindWithKey(Dee_TYPE(self)))(self, item, start, end, key) -#define DeeSeq_RFindWithKey(self, item, start, end, key) \ - (*DeeType_SeqCache_RequireRFindWithKey(Dee_TYPE(self)))(self, item, start, end, key) +#define DeeSeq_NonEmpty(self) (*DeeType_SeqCache_RequireNonEmpty(Dee_TYPE(self)))(self) /* Invoke sequence functions */ /* TODO: Remove the "new_" prefix and remove functions from "seq_mutable.c" */ -#define new_DeeSeqFind(self, item, start, end) \ - (*DeeType_SeqCache_RequireFind(Dee_TYPE(self)))(self, item, start, end) -#define new_DeeSeqFindWithKey(self, item, start, end, key) \ - (*DeeType_SeqCache_RequireFindWithKey(Dee_TYPE(self)))(self, item, start, end, key) -#define new_DeeSeqRFind(self, item, start, end) \ - (*DeeType_SeqCache_RequireRFind(Dee_TYPE(self)))(self, item, start, end) -#define new_DeeSeqRFindWithKey(self, item, start, end, key) \ - (*DeeType_SeqCache_RequireRFindWithKey(Dee_TYPE(self)))(self, item, start, end, key) -#define new_DeeSeq_Erase(self, index, count) \ - (*DeeType_SeqCache_RequireErase(Dee_TYPE(self)))(self, index, count) -#define new_DeeSeq_Insert(self, index, item) \ - (*DeeType_SeqCache_RequireInsert(Dee_TYPE(self)))(self, index, item) -#define new_DeeSeq_InsertAll(self, index, items) \ - (*DeeType_SeqCache_RequireInsertAll(Dee_TYPE(self)))(self, index, items) -#define new_DeeSeq_PushFront(self, item) \ - (*DeeType_SeqCache_RequirePushFront(Dee_TYPE(self)))(self, item) -#define new_DeeSeq_Append(self, item) \ - (*DeeType_SeqCache_RequireAppend(Dee_TYPE(self)))(self, item) -#define new_DeeSeq_Extend(self, items) \ - (*DeeType_SeqCache_RequireExtend(Dee_TYPE(self)))(self, items) -#define new_DeeSeq_XchItemIndex(self, index, value) \ - (*DeeType_SeqCache_RequireXchItemIndex(Dee_TYPE(self)))(self, index, value) -#define new_DeeSeq_Clear(self) \ - (*DeeType_SeqCache_RequireClear(Dee_TYPE(self)))(self) -#define new_DeeSeq_Pop(self, index) \ - (*DeeType_SeqCache_RequirePop(Dee_TYPE(self)))(self, index) -#define new_DeeSeq_Remove(self, item, start, end) \ - (*DeeType_SeqCache_RequireRemove(Dee_TYPE(self)))(self, item, start, end) -#define new_DeeSeq_RemoveWithKey(self, item, start, end, key) \ - (*DeeType_SeqCache_RequireRemoveWithKey(Dee_TYPE(self)))(self, item, start, end, key) -#define new_DeeSeq_RRemove(self, item, start, end) \ - (*DeeType_SeqCache_RequireRRemove(Dee_TYPE(self)))(self, item, start, end) -#define new_DeeSeq_RRemoveWithKey(self, item, start, end, key) \ - (*DeeType_SeqCache_RequireRRemoveWithKey(Dee_TYPE(self)))(self, item, start, end, key) -#define new_DeeSeq_RemoveAll(self, item, start, end, max) \ - (*DeeType_SeqCache_RequireRemoveAll(Dee_TYPE(self)))(self, item, start, end, max) -#define new_DeeSeq_RemoveAllWithKey(self, item, start, end, max, key) \ - (*DeeType_SeqCache_RequireRemoveAllWithKey(Dee_TYPE(self)))(self, item, start, end, max, key) -#define new_DeeSeq_RemoveIf(self, should, start, end, max) \ - (*DeeType_SeqCache_RequireRemoveIf(Dee_TYPE(self)))(self, should, start, end, max) -#define new_DeeSeq_Resize(self, newsize, filler) \ - (*DeeType_SeqCache_RequireResize(Dee_TYPE(self)))(self, newsize, filler) -#define new_DeeSeq_Fill(self, start, end, filler) \ - (*DeeType_SeqCache_RequireFill(Dee_TYPE(self)))(self, start, end, filler) -#define new_DeeSeq_Reverse(self, start, end) \ - (*DeeType_SeqCache_RequireReverse(Dee_TYPE(self)))(self, start, end) -#define new_DeeSeq_Reversed(self, start, end) \ - (*DeeType_SeqCache_RequireReversed(Dee_TYPE(self)))(self, start, end) -#define new_DeeSeq_Sort(self, start, end) \ - (*DeeType_SeqCache_RequireSort(Dee_TYPE(self)))(self, start, end) -#define new_DeeSeq_SortWithKey(self, start, end, key) \ - (*DeeType_SeqCache_RequireSortWithKey(Dee_TYPE(self)))(self, start, end, key) -#define new_DeeSeq_Sorted(self, start, end) \ - (*DeeType_SeqCache_RequireSorted(Dee_TYPE(self)))(self, start, end) -#define new_DeeSeq_SortedWithKey(self, start, end, key) \ - (*DeeType_SeqCache_RequireSortedWithKey(Dee_TYPE(self)))(self, start, end, key) +#define new_DeeSeqFind(self, item, start, end) (*DeeType_SeqCache_RequireFind(Dee_TYPE(self)))(self, item, start, end) +#define new_DeeSeqFindWithKey(self, item, start, end, key) (*DeeType_SeqCache_RequireFindWithKey(Dee_TYPE(self)))(self, item, start, end, key) +#define new_DeeSeqRFind(self, item, start, end) (*DeeType_SeqCache_RequireRFind(Dee_TYPE(self)))(self, item, start, end) +#define new_DeeSeqRFindWithKey(self, item, start, end, key) (*DeeType_SeqCache_RequireRFindWithKey(Dee_TYPE(self)))(self, item, start, end, key) +#define new_DeeSeq_Erase(self, index, count) (*DeeType_SeqCache_RequireErase(Dee_TYPE(self)))(self, index, count) +#define new_DeeSeq_Insert(self, index, item) (*DeeType_SeqCache_RequireInsert(Dee_TYPE(self)))(self, index, item) +#define new_DeeSeq_InsertAll(self, index, items) (*DeeType_SeqCache_RequireInsertAll(Dee_TYPE(self)))(self, index, items) +#define new_DeeSeq_PushFront(self, item) (*DeeType_SeqCache_RequirePushFront(Dee_TYPE(self)))(self, item) +#define new_DeeSeq_Append(self, item) (*DeeType_SeqCache_RequireAppend(Dee_TYPE(self)))(self, item) +#define new_DeeSeq_Extend(self, items) (*DeeType_SeqCache_RequireExtend(Dee_TYPE(self)))(self, items) +#define new_DeeSeq_XchItemIndex(self, index, value) (*DeeType_SeqCache_RequireXchItemIndex(Dee_TYPE(self)))(self, index, value) +#define new_DeeSeq_Clear(self) (*DeeType_SeqCache_RequireClear(Dee_TYPE(self)))(self) +#define new_DeeSeq_Pop(self, index) (*DeeType_SeqCache_RequirePop(Dee_TYPE(self)))(self, index) +#define new_DeeSeq_Remove(self, item, start, end) (*DeeType_SeqCache_RequireRemove(Dee_TYPE(self)))(self, item, start, end) +#define new_DeeSeq_RemoveWithKey(self, item, start, end, key) (*DeeType_SeqCache_RequireRemoveWithKey(Dee_TYPE(self)))(self, item, start, end, key) +#define new_DeeSeq_RRemove(self, item, start, end) (*DeeType_SeqCache_RequireRRemove(Dee_TYPE(self)))(self, item, start, end) +#define new_DeeSeq_RRemoveWithKey(self, item, start, end, key) (*DeeType_SeqCache_RequireRRemoveWithKey(Dee_TYPE(self)))(self, item, start, end, key) +#define new_DeeSeq_RemoveAll(self, item, start, end, max) (*DeeType_SeqCache_RequireRemoveAll(Dee_TYPE(self)))(self, item, start, end, max) +#define new_DeeSeq_RemoveAllWithKey(self, item, start, end, max, key) (*DeeType_SeqCache_RequireRemoveAllWithKey(Dee_TYPE(self)))(self, item, start, end, max, key) +#define new_DeeSeq_RemoveIf(self, should, start, end, max) (*DeeType_SeqCache_RequireRemoveIf(Dee_TYPE(self)))(self, should, start, end, max) +#define new_DeeSeq_Resize(self, newsize, filler) (*DeeType_SeqCache_RequireResize(Dee_TYPE(self)))(self, newsize, filler) +#define new_DeeSeq_Fill(self, start, end, filler) (*DeeType_SeqCache_RequireFill(Dee_TYPE(self)))(self, start, end, filler) +#define new_DeeSeq_Reverse(self, start, end) (*DeeType_SeqCache_RequireReverse(Dee_TYPE(self)))(self, start, end) +#define new_DeeSeq_Reversed(self, start, end) (*DeeType_SeqCache_RequireReversed(Dee_TYPE(self)))(self, start, end) +#define new_DeeSeq_Sort(self, start, end) (*DeeType_SeqCache_RequireSort(Dee_TYPE(self)))(self, start, end) +#define new_DeeSeq_SortWithKey(self, start, end, key) (*DeeType_SeqCache_RequireSortWithKey(Dee_TYPE(self)))(self, start, end, key) +#define new_DeeSeq_Sorted(self, start, end) (*DeeType_SeqCache_RequireSorted(Dee_TYPE(self)))(self, start, end) +#define new_DeeSeq_SortedWithKey(self, start, end, key) (*DeeType_SeqCache_RequireSortedWithKey(Dee_TYPE(self)))(self, start, end, key) +#define new_DeeSeq_BFind(self, item, start, end) (*DeeType_SeqCache_RequireBFind(Dee_TYPE(self)))(self, item, start, end) +#define new_DeeSeq_BFindWithKey(self, item, start, end, key) (*DeeType_SeqCache_RequireBFindWithKey(Dee_TYPE(self)))(self, item, start, end, key) +#define new_DeeSeq_BPosition(self, item, start, end) (*DeeType_SeqCache_RequireBPosition(Dee_TYPE(self)))(self, item, start, end) +#define new_DeeSeq_BPositionWithKey(self, item, start, end, key) (*DeeType_SeqCache_RequireBPositionWithKey(Dee_TYPE(self)))(self, item, start, end, key) +#define new_DeeSeq_BRange(self, item, start, end, result_range) (*DeeType_SeqCache_RequireBRange(Dee_TYPE(self)))(self, item, start, end, result_range) +#define new_DeeSeq_BRangeWithKey(self, item, start, end, key, result_range) (*DeeType_SeqCache_RequireBRangeWithKey(Dee_TYPE(self)))(self, item, start, end, key, result_range) +#define new_DeeSeq_BLocate(self, item, start, end) (*DeeType_SeqCache_RequireBLocate(Dee_TYPE(self)))(self, item, start, end) +#define new_DeeSeq_BLocateWithKey(self, item, start, end, key) (*DeeType_SeqCache_RequireBLocateWithKey(Dee_TYPE(self)))(self, item, start, end, key) + /* Possible implementations for sequence cache functions. */ INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL DeeSeq_DefaultForeachReverseWithSizeAndGetItemIndexFast(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); @@ -431,9 +430,9 @@ INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultExtendWithSizeAndTSCInser INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultExtendWithError(DeeObject *self, DeeObject *items); INTDEF WUNUSED NONNULL((1, 3)) DREF DeeObject *DCALL DeeSeq_DefaultXchItemIndexWithCallAttrXchItem(DeeObject *self, size_t index, DeeObject *value); -INTDEF WUNUSED NONNULL((1, 3)) DREF DeeObject *DCALL DeeSeq_DefaultXchItemIndexWithCallXchItemIndexDataFunction(DeeObject *self, size_t index, DeeObject *value); -INTDEF WUNUSED NONNULL((1, 3)) DREF DeeObject *DCALL DeeSeq_DefaultXchItemIndexWithCallXchItemIndexDataMethod(DeeObject *self, size_t index, DeeObject *value); -INTDEF WUNUSED NONNULL((1, 3)) DREF DeeObject *DCALL DeeSeq_DefaultXchItemIndexWithCallXchItemIndexDataKwMethod(DeeObject *self, size_t index, DeeObject *value); +INTDEF WUNUSED NONNULL((1, 3)) DREF DeeObject *DCALL DeeSeq_DefaultXchItemIndexWithCallXchItemDataFunction(DeeObject *self, size_t index, DeeObject *value); +INTDEF WUNUSED NONNULL((1, 3)) DREF DeeObject *DCALL DeeSeq_DefaultXchItemIndexWithCallXchItemDataMethod(DeeObject *self, size_t index, DeeObject *value); +INTDEF WUNUSED NONNULL((1, 3)) DREF DeeObject *DCALL DeeSeq_DefaultXchItemIndexWithCallXchItemDataKwMethod(DeeObject *self, size_t index, DeeObject *value); INTDEF WUNUSED NONNULL((1, 3)) DREF DeeObject *DCALL DeeSeq_DefaultXchItemIndexWithGetItemIndexAndSetItemIndex(DeeObject *self, size_t index, DeeObject *value); INTDEF WUNUSED NONNULL((1, 3)) DREF DeeObject *DCALL DeeSeq_DefaultXchItemIndexWithError(DeeObject *self, size_t index, DeeObject *value); @@ -584,6 +583,69 @@ INTDEF WUNUSED NONNULL((1, 4)) DREF DeeObject *DCALL DeeSeq_DefaultSortedWithKey INTDEF WUNUSED NONNULL((1, 4)) DREF DeeObject *DCALL DeeSeq_DefaultSortedWithKeyWithCopySizeAndTryGetItemIndex(DeeObject *self, size_t start, size_t end, DeeObject *key); INTDEF WUNUSED NONNULL((1, 4)) DREF DeeObject *DCALL DeeSeq_DefaultSortedWithKeyWithCopyForeachDefault(DeeObject *self, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBFindWithCallAttrBFind(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBFindWithCallBFindDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBFindWithCallBFindDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBFindWithCallBFindDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBFindWithTSCBRange(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBFindWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBFindWithError(DeeObject *self, DeeObject *item, size_t start, size_t end); + +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBFindWithKeyWithCallAttrBFind(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBFindWithKeyWithCallBFindDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBFindWithKeyWithCallBFindDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBFindWithKeyWithCallBFindDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBFindWithKeyWithTSCBRangeWithKey(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBFindWithKeyWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBFindWithKeyWithError(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); + +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBPositionWithCallAttrBPosition(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBPositionWithCallBPositionDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBPositionWithCallBPositionDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBPositionWithCallBPositionDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBPositionWithTSCBRange(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBPositionWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_DefaultBPositionWithError(DeeObject *self, DeeObject *item, size_t start, size_t end); + +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBPositionWithKeyWithCallAttrBPosition(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBPositionWithKeyWithCallBPositionDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBPositionWithKeyWithCallBPositionDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBPositionWithKeyWithCallBPositionDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBPositionWithKeyWithTSCBRangeWithKey(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBPositionWithKeyWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) size_t DCALL DeeSeq_DefaultBPositionWithKeyWithError(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); + +INTDEF WUNUSED NONNULL((1, 2, 5)) int DCALL DeeSeq_DefaultBRangeWithCallAttrBRange(DeeObject *self, DeeObject *item, size_t start, size_t end, size_t result_range[2]); +INTDEF WUNUSED NONNULL((1, 2, 5)) int DCALL DeeSeq_DefaultBRangeWithCallBRangeDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end, size_t result_range[2]); +INTDEF WUNUSED NONNULL((1, 2, 5)) int DCALL DeeSeq_DefaultBRangeWithCallBRangeDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, size_t result_range[2]); +INTDEF WUNUSED NONNULL((1, 2, 5)) int DCALL DeeSeq_DefaultBRangeWithCallBRangeDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, size_t result_range[2]); +INTDEF WUNUSED NONNULL((1, 2, 5)) int DCALL DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, size_t result_range[2]); +INTDEF WUNUSED NONNULL((1, 2, 5)) int DCALL DeeSeq_DefaultBRangeWithError(DeeObject *self, DeeObject *item, size_t start, size_t end, size_t result_range[2]); + +INTDEF WUNUSED NONNULL((1, 2, 5, 6)) int DCALL DeeSeq_DefaultBRangeWithKeyWithCallAttrBRange(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key, size_t result_range[2]); +INTDEF WUNUSED NONNULL((1, 2, 5, 6)) int DCALL DeeSeq_DefaultBRangeWithKeyWithCallBRangeDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key, size_t result_range[2]); +INTDEF WUNUSED NONNULL((1, 2, 5, 6)) int DCALL DeeSeq_DefaultBRangeWithKeyWithCallBRangeDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key, size_t result_range[2]); +INTDEF WUNUSED NONNULL((1, 2, 5, 6)) int DCALL DeeSeq_DefaultBRangeWithKeyWithCallBRangeDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key, size_t result_range[2]); +INTDEF WUNUSED NONNULL((1, 2, 5, 6)) int DCALL DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key, size_t result_range[2]); +INTDEF WUNUSED NONNULL((1, 2, 5, 6)) int DCALL DeeSeq_DefaultBRangeWithKeyWithError(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key, size_t result_range[2]); + +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithCallAttrBLocate(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithCallBLocateDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithCallBLocateDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithCallBLocateDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithTSCBFindAndGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithError(DeeObject *self, DeeObject *item, size_t start, size_t end); + +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithCallAttrBLocate(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithCallBLocateDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithCallBLocateDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithCallBLocateDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithTSCBFindWithKeyAndGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithError(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); + + /* Generic sequence function hooks (used as function pointers of `type_method' / `type_getset' of Sequence/Set/Mapping) */ @@ -618,8 +680,6 @@ INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL generic_seq_endswith_with_key(DeeObj /* Generic sequence mutable function pointers. */ INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_find(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_rfind(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); -INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_index(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); -INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_rindex(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_erase(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_insert(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_insertall(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); @@ -641,6 +701,10 @@ INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_reverse(DeeObject INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_reversed(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_sort(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_sorted(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); +INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_bfind(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); +INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_bposition(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); +INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_brange(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); +INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL generic_seq_blocate(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw); DECL_END diff --git a/src/deemon/runtime/kwlist.h b/src/deemon/runtime/kwlist.h index edca5256b..7b2c33753 100644 --- a/src/deemon/runtime/kwlist.h +++ b/src/deemon/runtime/kwlist.h @@ -82,6 +82,7 @@ local kw_lists = { {"index", "items"}, {"index", "value"}, {"index"}, + {"item", "start", "end"}, {"item", "start", "end", "key"}, {"item", "start", "end", "max", "key"}, {"should", "start", "end", "max"}, @@ -185,6 +186,7 @@ DECLARE_KWLIST(kwlist__index_items, { KEX("index", 0x77f34f0, 0x440d5888c0ff3081 DECLARE_KWLIST(kwlist__index_value, { KEX("index", 0x77f34f0, 0x440d5888c0ff3081), KEX("value", 0xd9093f6e, 0x69e7413ae0c88471), KEND }); DECLARE_KWLIST(kwlist__isbreak_scope_loc, { KEX("isbreak", 0xdb6a737a, 0xf4916531d0a5abe7), KEX("scope", 0x8b65b2f8, 0x52824a24d6447e5), KEX("loc", 0x4f1e6896, 0xc8a6c6e417ce00f9), KEND }); DECLARE_KWLIST(kwlist__item_key, { KEX("item", 0x91b22efe, 0xe78210b41247a693), KEX("key", 0xe29c6a44, 0x612dd31212e90587), KEND }); +DECLARE_KWLIST(kwlist__item_start_end, { KEX("item", 0x91b22efe, 0xe78210b41247a693), KEX("start", 0xa2ed6890, 0x80b621ce3c3982d5), KEX("end", 0x37fb4a05, 0x6de935c204dc3d01), KEND }); DECLARE_KWLIST(kwlist__item_start_end_key, { KEX("item", 0x91b22efe, 0xe78210b41247a693), KEX("start", 0xa2ed6890, 0x80b621ce3c3982d5), KEX("end", 0x37fb4a05, 0x6de935c204dc3d01), KEX("key", 0xe29c6a44, 0x612dd31212e90587), KEND }); DECLARE_KWLIST(kwlist__item_start_end_max_key, { KEX("item", 0x91b22efe, 0xe78210b41247a693), KEX("start", 0xa2ed6890, 0x80b621ce3c3982d5), KEX("end", 0x37fb4a05, 0x6de935c204dc3d01), KEX("max", 0xc293979b, 0x822bd5c706bd9850), KEX("key", 0xe29c6a44, 0x612dd31212e90587), KEND }); DECLARE_KWLIST(kwlist__key, { KEX("key", 0xe29c6a44, 0x612dd31212e90587), KEND }); diff --git a/src/deemon/runtime/strings.h b/src/deemon/runtime/strings.h index 7030622d2..28de62b80 100644 --- a/src/deemon/runtime/strings.h +++ b/src/deemon/runtime/strings.h @@ -139,6 +139,10 @@ local STRINGS = { "popfront", "popback", "frozen", + "bfind", + "bposition", + "brange", + "blocate", "revert", "advance", @@ -516,6 +520,18 @@ DEF_STRING(str_popback, "popback", 0xd84577aa, 0xb77f74a49a9cc289) #define Dee_HashStr__frozen _Dee_HashSelectC(0x82311b77, 0x7b55e2e6e642b6fd) DEF_STRING(str_frozen, "frozen", 0x82311b77, 0x7b55e2e6e642b6fd) #define STR_frozen DeeString_STR(&str_frozen) +#define Dee_HashStr__bfind _Dee_HashSelectC(0xdb39cc6c, 0x5ec07aef149314c7) +DEF_STRING(str_bfind, "bfind", 0xdb39cc6c, 0x5ec07aef149314c7) +#define STR_bfind DeeString_STR(&str_bfind) +#define Dee_HashStr__bposition _Dee_HashSelectC(0xba99f013, 0xc8f6389c9f293cb2) +DEF_STRING(str_bposition, "bposition", 0xba99f013, 0xc8f6389c9f293cb2) +#define STR_bposition DeeString_STR(&str_bposition) +#define Dee_HashStr__brange _Dee_HashSelectC(0xb132222e, 0xfed8bb16d0ac0dd2) +DEF_STRING(str_brange, "brange", 0xb132222e, 0xfed8bb16d0ac0dd2) +#define STR_brange DeeString_STR(&str_brange) +#define Dee_HashStr__blocate _Dee_HashSelectC(0x7aa979d3, 0xbda91c237d69489e) +DEF_STRING(str_blocate, "blocate", 0x7aa979d3, 0xbda91c237d69489e) +#define STR_blocate DeeString_STR(&str_blocate) #define Dee_HashStr__revert _Dee_HashSelectC(0x98ca826, 0x626b4fca0d39dcf2) DEF_STRING(str_revert, "revert", 0x98ca826, 0x626b4fca0d39dcf2) #define STR_revert DeeString_STR(&str_revert) diff --git a/util/test/deemon-sequence-bsearch.dee b/util/test/deemon-sequence-bsearch.dee index 09d8d877b..fb5b4e9a4 100644 --- a/util/test/deemon-sequence-bsearch.dee +++ b/util/test/deemon-sequence-bsearch.dee @@ -105,15 +105,10 @@ assert seq.blocateall(33) == [33]; function div10(x: int): int -> x / 10; /* Assert the use of `key' to alter object grouping. */ -assert seq.blocateall(10, div10) == [11, 12, 13]; -assert seq.blocateall(20, div10) == [21, 22, 22, 22, 23]; -assert seq.blocateall(30, div10) == [31, 32, 33]; - -/* Just so we've done so at least once, assert use of keyword arguments. */ assert seq.blocateall(10, key: div10) == [11, 12, 13]; assert seq.blocateall(20, key: div10) == [21, 22, 22, 22, 23]; assert seq.blocateall(30, key: div10) == [31, 32, 33]; -assert seq.blocateall(elem: 10, key: div10) == [11, 12, 13]; -assert seq.blocateall(elem: 20, key: div10) == [21, 22, 22, 22, 23]; -assert seq.blocateall(elem: 30, key: div10) == [31, 32, 33]; +assert seq.blocateall(item: 10, key: div10) == [11, 12, 13]; +assert seq.blocateall(item: 20, key: div10) == [21, 22, 22, 22, 23]; +assert seq.blocateall(item: 30, key: div10) == [31, 32, 33];