From caaecda7f7c40e9f3ac56dc2a7b93099b8d00865 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 11 Aug 2015 21:38:28 +0200 Subject: [PATCH] doc --- README.md | 1 + doc/intro.txt | 1 + src/data/CCBitField.mli | 39 ++++++++++++++++++--------------------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index d04e3b04..c6a53326 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ Documentation [here](http://cedeela.fr/~simon/software/containers). with fast merges - `CCHashconsedSet`, a set structure with sharing of sub-structures - `CCGraph`, a small collection of graph algorithms +- `CCBitField`, a type-safe implementation of bitfields that fit in `int` ### Containers.io diff --git a/doc/intro.txt b/doc/intro.txt index fd5258bd..df66e5fd 100644 --- a/doc/intro.txt +++ b/doc/intro.txt @@ -63,6 +63,7 @@ such as: Various data structures. {!modules: +CCBitField CCBV CCCache CCFQueue diff --git a/src/data/CCBitField.mli b/src/data/CCBitField.mli index 0e63a05e..b7da8920 100644 --- a/src/data/CCBitField.mli +++ b/src/data/CCBitField.mli @@ -6,6 +6,23 @@ up to 30 or 62 bits (depending on the architecture) in a relatively type-safe way. +{[ +module B = CCBitField.Make(struct end);; + +#install_printer B.pp;; + +let x = B.int ~name:"x" ~width:3;; +let y = B.int ~name:"y" ~width:2;; +let z = B.bool ~name:"z" ();; + +let f = B.(empty |> set x 3 |> set y 1);; + +B.get z f ;; + +B.(f |> set z true |> get z) ;; + +]} + {b status: experimental} @since NEXT_RELEASE *) @@ -75,27 +92,7 @@ module type BITFIELD = sig (** Print the bitfield using the current list of fields *) end -(** Create a new bitfield type, - -{[ -module B = CCBitField.Make(struct end);; - -#install_printer B.pp;; - -let x = B.int ~name:"x" ~width:3;; -let y = B.int ~name:"y" ~width:2;; -let z = B.bool ~name:"z" ();; - -let f = B.(empty |> set x 3 |> set y 1);; - -B.get z f ;; - -B.(f |> set z true |> get z) ;; - -]} - - -*) +(** Create a new bitfield type *) module Make(X : EMPTY) : BITFIELD (*$R