Home My Page Projects Code Snippets Project Openings SML/NJ
 Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

# SCM Repository

[smlnj] Diff of /sml/branches/idlbasis-devel/src/MLRISC/library/dynamic-array.sml
 [smlnj] / sml / branches / idlbasis-devel / src / MLRISC / library / dynamic-array.sml

# Diff of /sml/branches/idlbasis-devel/src/MLRISC/library/dynamic-array.sml

revision 1232, Tue Jun 4 21:11:15 2002 UTC revision 1233, Wed Jun 5 21:47:29 2002 UTC
# Line 41  Line 41
41              let val new_size  = Int.max(i+1,!n*2)              let val new_size  = Int.max(i+1,!n*2)
42                  val new_size  = if new_size < 10 then 10 else new_size                  val new_size  = if new_size < 10 then 10 else new_size
43                  val new_array = A.array(new_size,d)                  val new_array = A.array(new_size,d)
44              in  A.copy {src = a, si = 0, len = NONE, dst = new_array, di = 0};              in  A.copy {src = a, dst = new_array, di = 0};
45                  r := new_array;                  r := new_array;
46                  n := i+1;                  n := i+1;
47                  A.update(new_array, i, e)                  A.update(new_array, i, e)
# Line 49  Line 49
49
50       fun expandTo(arr as ARRAY(_, d, _), N) = update(arr, N-1, d)       fun expandTo(arr as ARRAY(_, d, _), N) = update(arr, N-1, d)
51
52    (*
53       fun extract (ARRAY(r as ref a, _, ref n), i, j) = A.extract (a, i, j)       fun extract (ARRAY(r as ref a, _, ref n), i, j) = A.extract (a, i, j)
54    *)
55
56       fun copy { src = ARRAY(ref a,_,sz), si, len, dst, di } =       fun vector (ARRAY (r as ref a, _, _)) = A.vector a
57         let val n = case len of SOME l => si + l
58                               | NONE   => !sz       fun copy { src = ARRAY(ref a,_,sz), dst, di } =
59           let val n = !sz
60             fun cp(i,j) =             fun cp(i,j) =
61                  if i < n then (update(dst,j,A.sub(a,i)); cp(i+1,j+1)) else ()                  if i < n then (update(dst,j,A.sub(a,i)); cp(i+1,j+1)) else ()
62         in  cp (si, di)         in  cp (0, di)
63         end         end
64
65       fun copyVec { src, si, len, dst = ARRAY(ref a,_,sz), di } =       fun copyVec { src, dst = ARRAY(ref a,_,sz), di } =
66         A.copyVec { src = src, si = si, len = len, dst = a, di = di }         A.copyVec { src = src, dst = a, di = di }
67
68       fun tabulate (n, f) =       fun tabulate (n, f) =
69           let val array   = A.tabulate(n, f)           let val array   = A.tabulate(n, f)
# Line 77  Line 80
80           end handle _ => raise Size           end handle _ => raise Size
81
82       fun app f (ARRAY (ref a,_,ref n)) =       fun app f (ARRAY (ref a,_,ref n)) =
83           A.appi (fn (_,x) => f x) (a,0,SOME n)           A.appi (fn (_,x) => f x) a
84
85       fun foldl f u (ARRAY (ref a,_,ref n)) =       fun foldl f u (ARRAY (ref a,_,ref n)) =
86          A.foldli (fn (_,x,y) => f (x,y)) u (a, 0, SOME n)          A.foldli (fn (_,x,y) => f (x,y)) u a
87
88       fun foldr f u (ARRAY (ref a,_,ref n)) =       fun foldr f u (ARRAY (ref a,_,ref n)) =
89          A.foldri (fn (_,x,y) => f (x,y)) u (a, 0, SOME n)          A.foldri (fn (_,x,y) => f (x,y)) u a
90
91       fun modify f (ARRAY (ref a,_,ref n)) =       fun modify f (ARRAY (ref a,_,ref n)) =
92          A.modifyi (fn (_,x) => f x) (a, 0, SOME n)          A.modifyi (fn (_,x) => f x) a
93
94         fun appi f (ARRAY(ref a,_,ref n)) = A.appi f a
95
96       fun appi f (ARRAY(ref a,_,ref n), i, j) = A.appi f (a, i, j)       fun foldli f u (ARRAY(ref a,_,ref n)) = A.foldli f u a
97
98       fun foldli f u (ARRAY(ref a,_,ref n), i, j) = A.foldli f u (a, i, j)       fun foldri f u (ARRAY(ref a,_,ref n)) = A.foldri f u a
99
100       fun foldri f u (ARRAY(ref a,_,ref n), i, j) = A.foldri f u (a, i, j)       fun modifyi f (ARRAY(ref a,_,ref n)) = A.modifyi f a
101
102       fun modifyi f (ARRAY(ref a,_,ref n), i, j) = A.modifyi f (a, i, j)       fun findi p (ARRAY(ref a,_,ref n)) = A.findi p a
103         fun find p (ARRAY(ref a,_,ref n)) = A.find p a
104         fun exists p (ARRAY(ref a,_,ref n)) = A.exists p a
105         fun all p (ARRAY(ref a,_,ref n)) = A.all p a
106         fun collate c (ARRAY(ref a, _, _), ARRAY(ref b,_,_)) = A.collate c (a, b)
107
108  end  end
109

Legend:
 Removed from v.1232 changed lines Added in v.1233