Commit graph

2915 commits

Author SHA1 Message Date
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
Simon Cruanes
4ff604015c
rework CI a tiny bit 2024-05-13 21:00:30 -04:00
Simon Cruanes
0b0dd83423
reformat all the things 2024-05-13 20:57:53 -04:00
Simon Cruanes
042d5b4f68
refactor byte buf: make the type public
it's time to let the types roam free, people.
2024-05-13 20:56:49 -04:00
Simon Cruanes
94b67deda4
remove dead file 2024-05-13 20:56:44 -04:00
Simon Cruanes
fcd4d3f6ec
add cons_when to CCListLabels 2024-04-19 09:52:13 -04:00
Nicola Mometto
4ff1853222
feat(CCList): add cons_when 2024-04-19 09:52:13 -04:00
Simon Cruanes
570e3f8d67
Merge pull request #450 from Bronsa/nicola/tup_pipe
feat(CCFun): add (||>)
2024-04-11 10:25:47 -04:00
Nicola Mometto
71233f2c1a chore: add since NEXT_RELEASE 2024-04-11 14:58:56 +01:00
Nicola Mometto
6a70c57253 feat(CCFun): add (|||>) 2024-04-11 14:54:07 +01:00
Nicola Mometto
2a21181580 feat(CCFun): add (||>) 2024-04-11 14:51:55 +01:00
Simon Cruanes
69cd3ca78d
Merge pull request #448 from c-cube/wip-pvec
containers.pvec
2024-01-16 14:25:58 -05:00
Simon Cruanes
41d8a7a968
add Pvec.equal 2024-01-16 14:20:09 -05:00
Master Builder
17eab9c3f4 CCVector: Add function foldi 2024-01-11 12:19:12 -05:00
Simon Cruanes
cb949e4c7f
more benchs 2024-01-10 12:48:33 -05:00
Simon Cruanes
813ea40ac5
comment 2024-01-08 23:49:55 -05:00
Simon Cruanes
b49f358d47
perf: more bench for pvec 2024-01-08 12:53:26 -05:00
Simon Cruanes
821fa6e3cf
more tests 2024-01-08 09:19:39 -05:00
Simon Cruanes
dd552fe334
more tests 2024-01-07 23:30:12 -05:00
Simon Cruanes
b9cc91fb96
pvec: implement iter_rev directly 2024-01-07 23:21:32 -05:00
Simon Cruanes
12ff3802ce
perf: implement iter separately from iteri 2024-01-07 23:17:57 -05:00
Simon Cruanes
a281476082
perf: reduce GC pressure by using a branching factor of 16 2024-01-07 23:17:39 -05:00
Simon Cruanes
8dca0ea78d
fix build 2024-01-06 22:45:42 -05:00
Simon Cruanes
04440deb39
small refactor 2024-01-06 17:17:06 -05:00
Simon Cruanes
81408b8e1b
add last to Pvec 2024-01-05 22:54:08 -05:00
Simon Cruanes
6a3cafa763
compat 2024-01-05 22:38:05 -05:00
Simon Cruanes
b9b6bf82b6
perf: restore branching factor to 32 2024-01-05 22:14:22 -05:00
Simon Cruanes
42967b2127
benchs: add pvec 2024-01-05 22:14:18 -05:00
Simon Cruanes
03e253a31c
fix pvec tests
(make choose's result irrelevant, only test whether it returns)
2024-01-05 21:54:41 -05:00