mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-09 04:35:29 -05:00
add CCKtree.force
This commit is contained in:
parent
394656660c
commit
118c9154bd
2 changed files with 9 additions and 0 deletions
|
|
@ -171,6 +171,10 @@ let bfs ?(pset=set_of_cmp ()) t =
|
|||
in
|
||||
bfs pset (FQ.push FQ.empty t)
|
||||
|
||||
let rec force t : ([`Nil | `Node of 'a * 'b list] as 'b) = match t() with
|
||||
| `Nil -> `Nil
|
||||
| `Node (x, l) -> `Node (x, List.map force l)
|
||||
|
||||
let find ?pset f t =
|
||||
let rec _find_kl f l = match l() with
|
||||
| `Nil -> None
|
||||
|
|
|
|||
|
|
@ -91,6 +91,11 @@ val dfs : ?pset:'a pset -> 'a t -> [ `Enter of 'a | `Exit of 'a ] klist
|
|||
val bfs : ?pset:'a pset -> 'a t -> 'a klist
|
||||
(** Breadth first traversal of the tree *)
|
||||
|
||||
val force : 'a t -> ([ `Nil | `Node of 'a * 'b list ] as 'b)
|
||||
(** [force t] evaluates [t] completely and returns a regular tree
|
||||
structure
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val find : ?pset:'a pset -> ('a -> 'b option) -> 'a t -> 'b option
|
||||
(** Look for an element that maps to [Some _] *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue