Commit graph

50 commits

Author SHA1 Message Date
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
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
Fardale
a30e471a6f
fix doc (#425) 2023-02-14 20:56:15 -05:00
Simon Cruanes
10865eaced reformat 2022-07-04 13:36:06 -04:00
Fardale
099f2e176f chore(doc): adapt module docstring for the index page 2021-11-11 14:40:35 +01:00
Simon Cruanes
add6a58cf5 prepare for 3.0~rc1 2020-07-28 18:15:05 -04:00
Fardale
01da25cead break: change pp functions to take unit printer for sep/stop/start
sep/stop/start -> pp_sep/pp_stop/pp_start
string -> unit printer
2020-07-27 22:57:29 -04:00
Fardale
c85c135157 break: remove klist type and functions from core 2020-07-23 16:32:52 +02:00
Fardale
8c3d716ab1 break: rename fonction from *std_seq* to *seq* 2020-07-23 16:32:52 +02:00
Fourchaux
53febce5a9
Comments presentation (#310)
* Comments presentation
2020-06-12 09:52:50 +02:00
JPR
0f9e51fbe3 Comments presentation 2020-04-26 16:17:17 -05:00
Simon Cruanes
d923795e1a remove slice APIs in string and array 2020-04-24 20:23:26 -04:00
Simon Cruanes
a767e4618d wip(3.0): remove deprecated functions, in particular sequence 2020-04-24 20:16:53 -04:00
Simon Cruanes
5126973173 prepare for 2.8 2019-12-14 17:50:35 -06:00
Simon Cruanes
138047ef11 feat: add {to,of,add}_{iter,std_seq} where relevant; deprecations
deprecate `seq` named functions (for `iter`)
deprecate klist functions (for `std_seq`)

close #231
2019-12-14 16:29:07 -06:00
Simon Cruanes
7cefde490b prepare for 2.7
remove mdx
2019-11-12 08:49:33 -06:00
Fardale
0dafceb708 Adding to_string (#270)
* add `CCArray.to_string`
* add `CCArrayLabels.to_string`
* add `CCList.to_string`
* add `CCListLabels.to_string`
* add `CCChar.to_string`
* add `CCPair.to_string`
* add `CCHeap.to_string`
* add `CCSet.to_string`
* add `CCVector.to_string`
2019-10-30 14:26:52 -05:00
Simon Cruanes
da2c9e7c7c doc: abide by odoc's whims 2018-11-02 20:25:37 -05:00
Simon Cruanes
1adfc01cf0 fix small detail s in CCHeap 2018-05-29 11:17:11 -05:00
juloo
ba633d5d3c Add CCHeap.Make_from_compare (#225)
Allow to pass modules implementing `compare` without implementing `leq`
2018-05-29 11:15:38 -05:00
JPR
1727cc8199 Few Comments corrections 2018-04-08 18:39:23 -05:00
Simon Cruanes
78d79c1317 chore: minor details in doc 2018-03-28 20:30:26 -05:00
JPR
d18d9fb636 Comments - Style & typos fixing 2018-03-15 23:09:31 -05:00
nathan moreau
3e2fbce3ee Comments - few changes 2018-02-07 14:36:03 +01:00
Simon Cruanes
c382c1c2e5 prepare for 2.0+alpha2 2018-02-01 19:18:17 -06:00
nathan moreau
00b2638ae7 Adding more comments 2018-01-30 14:07:05 +01:00
Simon Cruanes
2939dcbf1d rename CCChar.{print,pp} and CCHeap.print (closes #181) 2018-01-29 21:15:24 -06:00
Fardale
8c2cb3f244 [CCHeap] delete_once -> delete_one 2018-01-28 12:39:44 +01:00
Fardale
8ac62ca04b [CCHeap] add delete_once 2018-01-28 12:37:21 +01:00
Fardale
50d970852e [CCHeap] update comment delete_all 2018-01-28 12:36:37 +01:00
Fardale
4e9eeb50e5 add @since for delete_all 2018-01-27 23:48:47 +01:00
Fardale
7c7f66cd7b Add CCHeap.delete_all 2018-01-26 09:31:29 +01:00
Simon Cruanes
d45b341232 prepare for 1.1 2017-03-03 16:18:13 +01:00
Simon Cruanes
8627838faf add CCHeap.to_seq_sorted 2017-02-23 21:01:32 +01:00
Simon Cruanes
12b38f4c31 add CCHeap.to_list_sorted 2017-02-23 20:57:19 +01:00
Simon Cruanes
f0aecf3b8e add doc for of_list in relevant modules (close #85) 2016-12-29 11:39:21 +01:00
Simon Cruanes
13f6660373 cleanup and more tests in CCHeap 2016-07-04 23:25:55 +02:00
Simon Cruanes
a2179d4355 prepare for 0.16 2016-02-24 22:08:26 +01:00
Simon Cruanes
8a3b559970 breaking: change the signature of CCHeap.{of_gen,of_seq,of_klist} 2016-02-24 21:52:26 +01:00
Simon Cruanes
ac6900976a add a printer into CCHeap 2016-02-24 21:52:26 +01:00
Simon Cruanes
34445bead0 replace headers in the rest of containers core 2016-02-20 23:24:24 +01:00
Simon Cruanes
61465fa19a remove cgi/; move sub-libraries to their own subdir each; mv everything into src/ 2014-12-16 23:41:59 +01:00
Renamed from core/CCHeap.mli (Browse further)