Skip to content
This repository
Browse code

Remove default comparators from BatRefList, use BatList explicitly

  • Loading branch information...
commit 87cba02216270fa758a84c07026cb5d58630620e 1 parent 3c29430
Edgar Friendly authored April 02, 2012
13  src/batRefList.ml
@@ -18,9 +18,6 @@
18 18
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 19
  *)
20 20
 
21  
-
22  
-open BatList
23  
-
24 21
 exception Empty_list
25 22
 
26 23
 type 'a t = 'a list ref
@@ -47,14 +44,14 @@ let hd rl = try List.hd !rl with _ -> raise Empty_list
47 44
 let tl rl = try ref (List.tl !rl) with _ -> raise Empty_list
48 45
 let iter f rl = List.iter f !rl
49 46
 let for_all f rl = List.for_all f !rl
50  
-let map f rl = ref (List.map f !rl)
51  
-let transform f rl = rl := List.map f !rl
52  
-let map_list f rl = List.map f !rl
  47
+let map f rl = ref (BatList.map f !rl)
  48
+let transform f rl = rl := BatList.map f !rl
  49
+let map_list f rl = BatList.map f !rl
53 50
 let find f rl = List.find f !rl
54 51
 let rev rl = rl := List.rev !rl
55 52
 let find_exc f exn rl = try List.find f !rl with _ -> raise exn
56 53
 let exists f rl = List.exists f !rl
57  
-let sort ?(cmp=compare) rl = rl := List.sort cmp !rl
  54
+let sort ~cmp rl = rl := List.sort cmp !rl
58 55
 
59 56
 let rfind f rl = BatList.rfind f !rl
60 57
 
@@ -75,7 +72,7 @@ let remove_if pred rl = rl := BatList.remove_if pred !rl
75 72
 let remove_all rl item = rl := BatList.remove_all !rl item
76 73
 let filter pred rl = rl := List.filter pred !rl
77 74
 
78  
-let add_sort ?(cmp=compare) rl item =
  75
+let add_sort ~cmp rl item =
79 76
   let rec add_aux = function
80 77
   | x::lnext as l ->
81 78
       let r = cmp x item in
10  src/batRefList.mli
@@ -80,9 +80,8 @@ val add : 'a t -> 'a -> unit
80 80
 val push : 'a t -> 'a -> unit
81 81
 (** Adds an element at the head - O(1) *)
82 82
 
83  
-val add_sort : ?cmp:('a -> 'a -> int) -> 'a t -> 'a -> unit
84  
-(** Adds an element in a sorted list, using optional comparator
85  
-    or 'compare' as default. *)
  83
+val add_sort : cmp:('a -> 'a -> int) -> 'a t -> 'a -> unit
  84
+(** Adds an element in a sorted list, using the given comparator. *)
86 85
 
87 86
 val first : 'a t -> 'a
88 87
 (** Returns the first element or
@@ -162,9 +161,8 @@ val map_list : ('a -> 'b) -> 'a t -> 'b list
162 161
     and return the list constructed with
163 162
     the function returned values *)
164 163
 
165  
-val sort : ?cmp:('a -> 'a -> int) -> 'a t -> unit
166  
-(** Sort elements using the specified comparator
167  
-    or compare as default comparator *)
  164
+val sort : cmp:('a -> 'a -> int) -> 'a t -> unit
  165
+(** Sort elements using the specified comparator *)
168 166
 
169 167
 val filter : ('a -> bool) -> 'a t -> unit
170 168
 (** Remove all elements that do not match the

0 notes on commit 87cba02

Please sign in to comment.
Something went wrong with that request. Please try again.