PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/visualiser/flist.ml

http://github.com/hhughes/ocaml-frui
OCaml | 23 lines | 23 code | 0 blank | 0 comment | 0 complexity | 4283cb5386a30f15e0f4d43f5deb5b3c MD5 | raw file
 1class ['a] flist =
 2object (self)
 3  val mutable first = []
 4  val mutable last = []
 5  val mutable fs = []
 6  method lift (f : 'a -> unit) = 
 7    begin
 8      let l o = ignore (Froc.lift f o) in
 9      fs <- f :: fs;
10      List.iter l first;
11      List.iter l (List.rev last)
12    end
13  method lift_all o =
14    begin
15      let l f = ignore (Froc.lift f o) in
16      List.iter l fs
17    end
18  method list = List.rev_append (List.rev first) (List.rev last)
19  method push o = self#lift_all o; first <- o :: first
20  method push_end o = self#lift_all o; last <- o :: last
21  method pop = let hd = List.hd first in first <- List.tl first; hd
22  method pop_end = let hd = List.hd last in last <- List.tl last; hd
23end