Skip to content

Data structure implementations (Avl tree, Red-black tree, Splay tree, Heap) for Ocaml language

Notifications You must be signed in to change notification settings

aduraj/ocaml-data-structures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ocaml data structures

Run

  • ocaml -c library.mli
  • ocaml -c library.ml

in order to get library.cmi and library.cmo


Copy the generated files (cmi and cmo) to the lib directory inside your ocaml installation folder. The library is now available to all your ocaml apps. The library name is the capitalized file name: library.cmo -> Library.

In order to use a library just in a single application, copy the generated files to this application's directory.


In order to compile program.ml which uses library.cmo, run:

  • ocamlc graphics.cma library.cmo program.ml -o program

The Graphics library is required for all the libraries in this repository.


In order to load one of the libraries in the interactive mode, run:

  • #load "graphics.cma";;
  • #load "library.cmo";;

Each library provides module Int of signature Compare and functor Make(El:Compare) of signature appropriate for the library (e.g. Avltree).


Sample usage:

  • module M = Avltree.Make(Avltree.Int);;
  • let tree = M.empty();;

Methods for tree libraries:

  • empty : unit -> tree
  • insert : elem * tree -> tree
  • delete : elem * tree -> tree
  • member : elem * tree -> bool
  • isEmpty : tree -> bool
  • draw : tree -> unit

Methods for heap library:

  • empty : unit -> heap
  • isEmpty : heap -> bool
  • insert : elem * heap -> heap
  • findMin : heap -> elem
  • Draw : heap -> unit

There are sample programs in the tests directory (.ml + executables).


In order to run a program, type in shell:

  • ocamlrun executable

About

Data structure implementations (Avl tree, Red-black tree, Splay tree, Heap) for Ocaml language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages