mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
update of containers.mllib to include SplayMap; update of README;
SplayMap.iter/fold now traverse in ascending order
This commit is contained in:
parent
6c1f7fb950
commit
6118e61edc
4 changed files with 8 additions and 3 deletions
|
|
@ -9,7 +9,8 @@ The design is centerred around polymorphism rather than functors. Such
|
||||||
structures comprise:
|
structures comprise:
|
||||||
|
|
||||||
- `PHashtbl`, a polymorphic hashtable (with open addressing)
|
- `PHashtbl`, a polymorphic hashtable (with open addressing)
|
||||||
- `SplayTree`, a polymorphic splay heap implementation
|
- `SplayTree`, a polymorphic splay heap implementation (not quite finished)
|
||||||
|
- `SplayMap`, a polymorphic functional map based on splay trees
|
||||||
- `Heap`, an imperative heap based on `SplayTree`
|
- `Heap`, an imperative heap based on `SplayTree`
|
||||||
- `Graph`, a polymorphic imperative directed graph (on top of `PHashtbl`)
|
- `Graph`, a polymorphic imperative directed graph (on top of `PHashtbl`)
|
||||||
- `Hashset`, a polymorphic imperative set on top of `PHashtbl`
|
- `Hashset`, a polymorphic imperative set on top of `PHashtbl`
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,6 @@ PHashtbl
|
||||||
Sequence
|
Sequence
|
||||||
SkipList
|
SkipList
|
||||||
SplayTree
|
SplayTree
|
||||||
|
SplayMap
|
||||||
Univ
|
Univ
|
||||||
Vector
|
Vector
|
||||||
|
|
|
||||||
|
|
@ -168,8 +168,8 @@ let iter t f =
|
||||||
let rec iter t = match t with
|
let rec iter t = match t with
|
||||||
| Empty -> ()
|
| Empty -> ()
|
||||||
| Node (k, v, l, r) ->
|
| Node (k, v, l, r) ->
|
||||||
f k v;
|
|
||||||
iter l;
|
iter l;
|
||||||
|
f k v;
|
||||||
iter r
|
iter r
|
||||||
in iter t.tree
|
in iter t.tree
|
||||||
|
|
||||||
|
|
@ -177,8 +177,8 @@ let fold t acc f =
|
||||||
let rec fold acc t = match t with
|
let rec fold acc t = match t with
|
||||||
| Empty -> acc
|
| Empty -> acc
|
||||||
| Node (k, v, l, r) ->
|
| Node (k, v, l, r) ->
|
||||||
let acc = f acc k v in
|
|
||||||
let acc = fold acc l in
|
let acc = fold acc l in
|
||||||
|
let acc = f acc k v in
|
||||||
fold acc r
|
fold acc r
|
||||||
in
|
in
|
||||||
fold acc t.tree
|
fold acc t.tree
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
(** {1 Functional Maps} *)
|
(** {1 Functional Maps} *)
|
||||||
|
|
||||||
|
(* TODO: map-wide operations: merge, compare, equal, for_all, exists,
|
||||||
|
batch (sorted) add, partition, split, max_elt, min_elt, map... *)
|
||||||
|
|
||||||
type ('a, 'b) t
|
type ('a, 'b) t
|
||||||
(** Tree with keys of type 'a, and values of type 'b *)
|
(** Tree with keys of type 'a, and values of type 'b *)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue