diff --git a/README.md b/README.md index aed9d58c..47de8bdd 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/containers.mllib b/containers.mllib index 5ab9221f..57cd05f2 100644 --- a/containers.mllib +++ b/containers.mllib @@ -13,5 +13,6 @@ PHashtbl Sequence SkipList SplayTree +SplayMap Univ Vector diff --git a/splayMap.ml b/splayMap.ml index 07a6bd67..d0afedbe 100644 --- a/splayMap.ml +++ b/splayMap.ml @@ -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 diff --git a/splayMap.mli b/splayMap.mli index 1af1388f..f504da79 100644 --- a/splayMap.mli +++ b/splayMap.mli @@ -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 *)