1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset= ISO-8859-1">
<TITLE>
Module Weak: arrays of weak pointers
</TITLE>
</HEAD>
<BODY >
<A HREF="manual058.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<HR>
<H2>17.29 Module <TT>Weak</TT>: arrays of weak pointers</H2><A NAME="s:Weak"></A>
<A NAME="@manual523"></A><PRE>
type 'a t;;
</PRE>
<BLOCKQUOTE>
The type of arrays of weak pointers (weak arrays). A weak
pointer is an object that the garbage collector may erase at
any time.
A weak pointer is said to be full if it points to an object,
empty if the object was erased by the GC.</BLOCKQUOTE>
<PRE>
val create : int -> 'a t;;
</PRE>
<A NAME="@manual524"></A><BLOCKQUOTE>
<CODE>Weak.create n</CODE> returns a new weak array of length <CODE>n</CODE>.
All the pointers are initially empty.</BLOCKQUOTE>
<PRE>
val length : 'a t -> int;;
</PRE>
<A NAME="@manual525"></A><BLOCKQUOTE>
<CODE>Weak.length ar</CODE> returns the length (number of elements) of
<CODE>ar</CODE>.</BLOCKQUOTE>
<PRE>
val set : 'a t -> int -> 'a option -> unit;;
</PRE>
<A NAME="@manual526"></A><BLOCKQUOTE>
<CODE>Weak.set ar n (Some el)</CODE> sets the <CODE>n</CODE>th cell of <CODE>ar</CODE> to be a
(full) pointer to <CODE>el</CODE>; <CODE>Weak.set ar n None</CODE> sets the <CODE>n</CODE>th
cell of <CODE>ar</CODE> to empty.
Raise <CODE>Invalid_argument "Weak.set"</CODE> if <CODE>n</CODE> is not in the range
0 to <CODE>Weak.length a - 1</CODE>.</BLOCKQUOTE>
<PRE>
val get : 'a t -> int -> 'a option;;
</PRE>
<A NAME="@manual527"></A><BLOCKQUOTE>
<CODE>Weak.get ar n</CODE> returns None if the <CODE>n</CODE>th cell of <CODE>ar</CODE> is
empty, <CODE>Some x</CODE> (where <CODE>x</CODE> is the object) if it is full.
Raise <CODE>Invalid_argument "Weak.get"</CODE> if <CODE>n</CODE> is not in the range
0 to <CODE>Weak.length a - 1</CODE>.</BLOCKQUOTE>
<PRE>
val check: 'a t -> int -> bool;;
</PRE>
<A NAME="@manual528"></A><BLOCKQUOTE>
<CODE>Weak.check ar n</CODE> returns <CODE>true</CODE> if the <CODE>n</CODE>th cell of <CODE>ar</CODE> is
full, <CODE>false</CODE> if it is empty. Note that even if <CODE>Weak.check ar n</CODE>
returns <CODE>true</CODE>, a subsequent <CODE>Weak.get ar n</CODE> can return <CODE>None</CODE>.</BLOCKQUOTE>
<PRE>
val fill: 'a t -> int -> int -> 'a option -> unit;;
</PRE>
<A NAME="@manual529"></A><BLOCKQUOTE>
<CODE>Weak.fill ar ofs len el</CODE> sets to <CODE>el</CODE> all pointers of <CODE>ar</CODE> from
<CODE>ofs</CODE> to <CODE>ofs + len - 1</CODE>. Raise <CODE>Invalid_argument "Weak.fill"</CODE>
if <CODE>ofs</CODE> and <CODE>len</CODE> do not designate a valid subarray of <CODE>a</CODE>.</BLOCKQUOTE>
<PRE>
val blit : 'a t -> int -> 'a t -> int -> int -> unit;;
</PRE>
<A NAME="@manual530"></A><BLOCKQUOTE>
<CODE>Weak.blit ar1 off1 ar2 off2 len</CODE> copies <CODE>len</CODE> weak pointers
from <CODE>ar1</CODE> (starting at <CODE>off1</CODE>) to <CODE>ar2</CODE> (starting at <CODE>off2</CODE>).
It works correctly even if <CODE>ar1</CODE> and <CODE>ar2</CODE> are the same.
Raise <CODE>Invalid_argument "Weak.blit"</CODE> if <CODE>off1</CODE> and <CODE>len</CODE> do
not designate a valid subarray of <CODE>ar1</CODE>, or if <CODE>off2</CODE> and <CODE>len</CODE>
do not designate a valid subarray of <CODE>ar2</CODE>.</BLOCKQUOTE>
<HR>
<A HREF="manual058.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
</BODY>
</HTML>
|