mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -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:
|
||||
|
||||
- `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`
|
||||
- `Graph`, a polymorphic imperative directed graph (on top of `PHashtbl`)
|
||||
- `Hashset`, a polymorphic imperative set on top of `PHashtbl`
|
||||
|
|
|
|||
|
|
@ -13,5 +13,6 @@ PHashtbl
|
|||
Sequence
|
||||
SkipList
|
||||
SplayTree
|
||||
SplayMap
|
||||
Univ
|
||||
Vector
|
||||
|
|
|
|||
|
|
@ -168,8 +168,8 @@ let iter t f =
|
|||
let rec iter t = match t with
|
||||
| Empty -> ()
|
||||
| Node (k, v, l, r) ->
|
||||
f k v;
|
||||
iter l;
|
||||
f k v;
|
||||
iter r
|
||||
in iter t.tree
|
||||
|
||||
|
|
@ -177,8 +177,8 @@ let fold t acc f =
|
|||
let rec fold acc t = match t with
|
||||
| Empty -> acc
|
||||
| Node (k, v, l, r) ->
|
||||
let acc = f acc k v in
|
||||
let acc = fold acc l in
|
||||
let acc = f acc k v in
|
||||
fold acc r
|
||||
in
|
||||
fold acc t.tree
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
(** {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
|
||||
(** Tree with keys of type 'a, and values of type 'b *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue