summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitya Selivanov <0x7fffff@guattari.ru>2022-08-07 08:37:53 +0400
committerMitya Selivanov <0x7fffff@guattari.ru>2022-08-07 08:37:53 +0400
commit4429ed09b548518dbffce7ec77ddf5a8b09484b2 (patch)
treed3541ddc0077517c861fd0ed22a21a83618754b5
parentfd458396b376d0f9fff3dd5a03b1ef95c8cf870e (diff)
downloadkit-4429ed09b548518dbffce7ec77ddf5a8b09484b2.zip
Refactor
-rw-r--r--README.md1
-rw-r--r--source/kit/lower_bound.h52
2 files changed, 27 insertions, 26 deletions
diff --git a/README.md b/README.md
index e19d0d6..ad780ac 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
# kit
- Unit-testing
- Async function
+- Lower bound
- Dynamic array
- Input buffer
diff --git a/source/kit/lower_bound.h b/source/kit/lower_bound.h
index 5b04557..fee1648 100644
--- a/source/kit/lower_bound.h
+++ b/source/kit/lower_bound.h
@@ -5,34 +5,34 @@
extern "C" {
#endif
-#define KIT_LOWER_BOUND(return_val, array, value, op) \
- { \
- ptrdiff_t position_ = 0; \
- ptrdiff_t count_ = (array).size; \
- while (count_ > 0) { \
- ptrdiff_t delta_ = count_ / 2; \
- if (op((array).values[position_ + delta_], (value))) { \
- position_ += delta_ + 1; \
- count_ -= delta_ + 1; \
- } else \
- count_ = delta_; \
- } \
- (return_val) = position_; \
+#define KIT_LOWER_BOUND(return_val, array, value, op) \
+ { \
+ ptrdiff_t position_ = 0; \
+ ptrdiff_t count_ = (array).size; \
+ while (count_ > 0) { \
+ ptrdiff_t delta_ = count_ / 2; \
+ if ((op) ((array).values[position_ + delta_], (value))) { \
+ position_ += delta_ + 1; \
+ count_ -= delta_ + 1; \
+ } else \
+ count_ = delta_; \
+ } \
+ (return_val) = position_; \
}
-#define KIT_LOWER_BOUND_REF(return_val, array, value, op) \
- { \
- ptrdiff_t position_ = 0; \
- ptrdiff_t count_ = (array).size; \
- while (count_ > 0) { \
- ptrdiff_t delta_ = count_ / 2; \
- if (op((array).values + position_ + delta_, &(value))) { \
- position_ += delta_ + 1; \
- count_ -= delta_ + 1; \
- } else \
- count_ = delta_; \
- } \
- (return_val) = position_; \
+#define KIT_LOWER_BOUND_REF(return_val, array, value, op) \
+ { \
+ ptrdiff_t position_ = 0; \
+ ptrdiff_t count_ = (array).size; \
+ while (count_ > 0) { \
+ ptrdiff_t delta_ = count_ / 2; \
+ if ((op) ((array).values + position_ + delta_, &(value))) { \
+ position_ += delta_ + 1; \
+ count_ -= delta_ + 1; \
+ } else \
+ count_ = delta_; \
+ } \
+ (return_val) = position_; \
}
#ifdef __cplusplus