Permalink
Browse files

sauvegarde avant de passer au distribue

  • Loading branch information...
1 parent 13268e5 commit b4404d42be6f1c0374d209894e79fc6f60853036 @SylvainGBR committed May 7, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 my_queue.ml
View
@@ -0,0 +1,23 @@
+ type 'a t = ('a list * 'a list) ref
+ exception Empty
+ let create () = ref ([], [])
+
+ let add x queue =
+ let front, back = !queue in
+ queue := (x::front, back)
+
+ let push x queue =
+ let front, back = !queue in
+ queue := (front, x::back)
+
+ let rec take queue =
+ match !queue with
+ (front, x :: back) ->
+ queue := (front, back);
+ x
+ | ([], []) ->
+ raise Empty
+ | (front, []) ->
+ queue := ([], List.rev front);
+ take queue
+

0 comments on commit b4404d4

Please sign in to comment.