Commit graph

2893 commits

Author SHA1 Message Date
Simon Cruanes
477e9cc7ca
remove warning in tests 2024-11-18 12:22:15 -05:00
Simon Cruanes
921db438f2
chore: in CI, run tests in release profile
this is required to be able to repro #454
2024-11-18 12:22:15 -05:00
Simon Cruanes
303f51f93d
chore: add 4.10 to compat matrix 2024-11-18 12:22:15 -05:00
Simon Cruanes
6dcaddb7c6
fixes and format 2024-11-15 11:02:38 -05:00
seprov
8d8f1d4145
Add split_result (#459)
add `CCList.split_result` (@seprov)
2024-11-15 11:01:20 -05:00
Fardale
9cfedad7ba feat: add pretty printer to CCMultiSet 2024-11-05 18:25:51 +01:00
Simon Cruanes
9bef25b6e2
format 2024-10-02 12:31:53 -04:00
Simon Cruanes
afb93cfc43
Merge pull request #457 from gmevel/linear-heap-building
Improvements to CCHeap
2024-10-02 10:04:42 -04:00
Simon Cruanes
3c530f47f4
Merge branch 'main' into linear-heap-building 2024-10-02 10:04:34 -04:00
Simon Cruanes
3efaa02d9d
update test output 2024-09-17 14:50:42 -04:00
Simon Cruanes
69f0e9b624
test: better regression test for #454 2024-09-17 14:04:09 -04:00
Simon Cruanes
c959e396b3
fix #454: work around a weird miscompilation 2024-09-17 12:51:07 -04:00
Simon Cruanes
6ab811f79b
prepare for 3.14 2024-09-10 08:47:46 -04:00
Simon Cruanes
9f8c2efe64
add missing @since tags 2024-09-03 13:12:12 -04:00
Simon Cruanes
07cfdb0d94
format 2024-09-03 13:11:57 -04:00
Simon Cruanes
5abb63517c
Merge pull request #458 from benbellick/add-predicate-combinator
predicate combinators: and_p and or_p
2024-09-03 13:11:50 -04:00
Benjamin Bellick
c6cb572230 and_p -> and_pred, or_p -> or_pred 2024-09-03 11:59:43 -05:00
Ben Bellick
1dc046c6e9 fix formatting 2024-08-24 10:53:59 -05:00
Ben Bellick
df0e442956 predicate combinators: and_p and or_p 2024-08-24 10:26:01 -05:00
Simon Cruanes
65fc920427
feat pp: add a bunch of extensions
thanks to @grayswandyr
2024-08-19 12:17:58 -04:00
Glen Mével
5d315503e1 CCHeap: building from almost-sorted sequences 2024-08-09 14:46:17 +02:00
Glen Mével
a24e1f7472 doc/CCHeap: fix English, improve wording, add sections 2024-07-31 17:50:35 +02:00
Glen Mével
13db1c31e9 tests/CCHeap: add tests 2024-07-31 16:03:06 +02:00
Glen Mével
92676f5513 tests/CCHeap: reorder tests 2024-07-31 03:27:52 +02:00
Glen Mével
78e67a9f4a tests/CCHeap: improve existing tests
- label all tests
- decouple tests about different heap functions
- random instances now have better coverage of possible cases:
  + more variability in size
    (previously, some tests were limited to a fixed size)
  + high probability of duplicates
    (previously, the probability of duplicates was negligible,
    because elements were drawn uniformly from the full `int` range)
- the test for `of_list, take_exn` is now more precise
  (added a duplicate element)
- the test for `to_list_sorted` is now more precise
  (checks that the resulting list is what we want,
  instead of just checking that it is sorted)
- the test for `filter` is now more precise
  (also checks that no element has been spuriously dropped)
- more uniform style for easier reading, using `|>`
2024-07-31 03:27:52 +02:00
Glen Mével
fdfc806afb CCHeap: avoid boxing in delete_one 2024-07-31 03:27:52 +02:00
Glen Mével
6c810eb83d doc/CCHeap: document (==) for merge 2024-07-31 03:27:52 +02:00
Glen Mével
3f95fd44e6 perf/CCHeap: filter, delete_all in O(n) and ensure (==)
- for `delete_all` this is a bugfix
  (physical equality was documented but not implemented)
- `delete_one` is unchanged, it already had complexity O(n)
  and ensured physical equality
2024-07-31 03:27:49 +02:00
Glen Mével
806bb8c7bc perf/CCHeap: heap building in O(n) 2024-07-31 02:19:33 +02:00
Glen Mével
cc2dd6d829 doc/CCHeap: move filter down 2024-07-27 04:57:43 +02:00
Glen Mével
8349a4d244 doc/CCHeap: fix grammar, improve doc of delete_{one,all} 2024-07-27 04:57:41 +02:00
Glen Mével
793bad1e5b doc/CCHeap: document complexities
Committing to these complexities in documentation is not a constraint
for representation of heaps, because they are achieved by every
well-known representation (for some of them, in amortized time):

https://en.wikipedia.org/wiki/Template:Heap_Running_Times

- `find_min`: O(1)
- `take`: O(log n)
- `insert`: O(log n)
- `merge`: O(log(m+n)) (excepted binary heaps which only achieve O(m+n))
- `add_seq`: O(n log(m+n)) (trivially, by repeated insertion)
  + this can be improved to O(log(m) + n), regardless of the
    representation of heaps (to be done in a later commit)
- `of_seq`: O(n log n) (ditto: can be improved to O(n))

Less trivial:

- `filter`, `delete_{one,all}`:

  + O(n) can be achieved for any reasonable representation of heaps, by
    using `of_seq` and `to_seq` which, as said, can always be made O(n).

  + With the current implementation, it is not obvious, but the
    complexity of `filter` and `delete_all` is Θ(n log n); the
    complexity of `delete_one` is O(n). Indeed, node rebuilding with
    `_make_node` is in O(1), merging is in Θ(log n), and every element
    deletion induces one merge; there are heap instances that achieve
    the worst case Ω(n log n), for instance:

                     x
                    / \
                   x   y
                  / \
                ...  y
                /
               x
              / \
             h   y

    with n/3 occurrences of x, n/3 occurrences of y, a sub-heap h of n/3
    elements, and when y is greater than all elements of h; then,
    deleting all occurrences of x performs the following computation:

        merge (merge (merge (merge h y) …) y) y

    where each `merge` takes time Θ(log n).
2024-07-27 04:55:40 +02:00
Glen Mével
8666faf257 doc/CCHeap: uniformize doc of conversion functions 2024-07-26 22:34:13 +02:00
Glen Mével
6bd5d3aacf doc/CCHeap: reorder conversion functions 2024-07-26 22:17:05 +02:00
Simon Cruanes
02ac5bd78a
add @since tags 2024-07-19 14:06:06 -04:00
Simon Cruanes
cb14c0d04b
format 2024-07-19 14:04:00 -04:00
NoahBatchelor
e933995733
Kleisli Composition Operator and Apply_or Added (#455)
Added the Kleisli composition operator for Option, Result, and CCFun.
2024-07-19 14:03:52 -04:00
Simon Cruanes
60bd3ae1d6 perf: use a monomorphic impl for CCMonomorphic.{min,max}
close #452
2024-07-09 10:13:50 -04:00
Simon Cruanes
99bfa200af
CI: compile on 5.2 2024-05-16 14:21:57 -04:00
Simon Cruanes
944410d3c7
CI: run all tests on linux and various OCaml versions
and run macOS stuff only for 5.1
2024-05-13 22:36:16 -04:00
Simon Cruanes
2e276002c6
format 2024-05-13 22:06:31 -04:00
Simon Cruanes
53b3f75d64
docs 2024-05-13 21:54:33 -04:00
Simon Cruanes
f5aa4de6e7
add CCByte_buffer.to_slice 2024-05-13 21:52:46 -04:00
Simon Cruanes
c29083c216
richer API for byte_buf 2024-05-13 21:51:27 -04:00
Simon Cruanes
14dc772eba
format 2024-05-13 21:43:29 -04:00
Simon Cruanes
040fe2f97c
move to dune 3.0, fix warnings 2024-05-13 21:42:54 -04:00
Simon Cruanes
8eaa2b6429
improve API for byte slice 2024-05-13 21:34:05 -04:00
Simon Cruanes
5a56269b6f
gitignore 2024-05-13 21:07:08 -04:00
Simon Cruanes
c299b32309
helper script to run benchs 2024-05-13 21:05:55 -04:00
Simon Cruanes
8b60f52377
add byte_slice module, fix warnings 2024-05-13 21:05:06 -04:00