Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004952OCamlstandard librarypublic2010-01-02 19:492016-12-07 18:32
ReporterBasile Starynkevitch 
Assigned Tofrisch 
PrioritynormalSeverityfeatureReproducibilityhave not tried
PlatformOSOS Version
Product Version 
Target VersionFixed in Version4.05.0 +dev/beta1/beta2/beta3/rc1 
Summary0004952: wish: after functions in ordered types like Map or Set
DescriptionIl would be quite useful to be able to get, inside a Map, the entry (if any) after a given key.

So I would dream of an additional function inside Map.S

(** [after k m] retrieve the next key, that is the lowest [nk] such that the map [m] contains a binding for [nk] and with [nk] compared greater than [k]. If no such key exist, raises [Not_found] **)
val after: key -> 'a t -> key

Likewise, it would be useful to be able to get, inside a Set, the element (if any) next to a given one.

So I would dream of an additional function inside Set.S

(** [next x s] returns the element [y] after the given [x] in set [s], or raises [Not_found] if no such element exist (i.e. if [s] is empty or if [x] is the maximal element. *)
val next: elt -> t -> elt

Additional InformationThe wished can be defined using Set.S.split (but that might not be efficient) and Set.S.min.

One could also wish the dual Set.S.previous.

Both functions have the following uses:

* the notion of good orders in math.

* in general, implement iterating co-routines (or iteration in CPS style) in Set-s or Map-s.

* in particular, they would be quite useful in some graphical interface applications. For example, suppose one code an editor using LabGtk & GText.buffer & GText.view. If one wants to have some sensitive words or text fragments, it would be useful to find e.g. the iter after a given line, etc..

Happy New Year 2010!


Basile Starynkevitch
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
frisch (developer)
2016-12-07 18:32

Addressed by Map.find_first/find_last in 4.05.

- Issue History
Date Modified Username Field Change
2010-01-02 19:49 Basile Starynkevitch New Issue
2010-01-07 15:47 doligez Status new => acknowledged
2016-12-07 14:14 shinwell Category OCaml general => OCaml standard library
2016-12-07 18:32 frisch Note Added: 0016789
2016-12-07 18:32 frisch Status acknowledged => resolved
2016-12-07 18:32 frisch Fixed in Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2016-12-07 18:32 frisch Resolution open => fixed
2016-12-07 18:32 frisch Assigned To => frisch
2017-02-23 16:43 doligez Category OCaml standard library => standard library

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker