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/trunk/system/Basis/Implementation/char-array.sml
ViewVC logotype

Diff of /sml/trunk/system/Basis/Implementation/char-array.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2162, Thu Nov 2 21:20:47 2006 UTC revision 4785, Wed Sep 5 14:05:17 2018 UTC
# Line 1  Line 1 
1  (* char-array.sml  (* char-array.sml
2   *   *
3   * COPYRIGHT (c) 1994 AT&T Bell Labs.   * COPYRIGHT (c) 2015 The Fellowship of SML/NJ (http://www.smlnj.org)
4   *   * All rights reserved.
5   *)   *)
6    
7  structure CharArray : MONO_ARRAY =  structure CharArray : MONO_ARRAY =
# Line 11  Line 11 
11    
12      (* fast add/subtract avoiding the overflow test *)      (* fast add/subtract avoiding the overflow test *)
13      infix -- ++      infix -- ++
14    (* 64BIT: FIXME *)
15      fun x -- y = InlineT.Word31.copyt_int31 (InlineT.Word31.copyf_int31 x -      fun x -- y = InlineT.Word31.copyt_int31 (InlineT.Word31.copyf_int31 x -
16                                               InlineT.Word31.copyf_int31 y)                                               InlineT.Word31.copyf_int31 y)
17      fun x ++ y = InlineT.Word31.copyt_int31 (InlineT.Word31.copyf_int31 x +      fun x ++ y = InlineT.Word31.copyt_int31 (InlineT.Word31.copyf_int31 x +
# Line 221  Line 222 
222      in      in
223          coll 0          coll 0
224      end      end
225    
226      (* added for Basis Library proposal 2015-003 *)
227        fun toList arr = foldr op :: [] arr
228    
229        fun fromVector v = let
230              val n = vlength v
231              in
232                if (n = 0)
233                  then A.newArray0()
234                  else let
235                    val arr = A.create n
236                    fun fill i = if (i < n)
237                          then (uupd(arr, i, vusub(v, i)); fill(i ++ 1))
238                          else arr
239                    in
240                      fill 0
241                    end
242              end
243    
244        val toVector = vector
245    
246    end (* CharArray *)    end (* CharArray *)

Legend:
Removed from v.2162  
changed lines
  Added in v.4785

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0