@@ -11,4 +11,31 @@ A C<Buf> is a mutable sequence of (usually unsigned) integers.
11
11
my $b = Buf.new(1, 2, 3);
12
12
$b[1] = 42;
13
13
14
+ = head1 Methods
15
+
16
+ = head2 method subbuf-rw
17
+
18
+ method subbuf-rw($from, $length?)
19
+
20
+ A mutable version of C < subbuf > that returns a L < Proxy|/type/Proxy > functioning as a
21
+ writable reference to a part of a buffer. Its first argument, C < $from >
22
+ specifies the index in the buffer from which a substitution should occur, and
23
+ its last argument, C < $length > specifies how many elements are to be replaced.
24
+
25
+ For example, to replace one element at index 3 with two elements, C < 100 > and C < 101 > :
26
+
27
+ my Buf $b .= new(0..5);
28
+ $b.subbuf-rw(3,1) = Buf.new(100, 101);
29
+ dd $b; # OUTPUT: Buf $b = Buf.new(0,1,2,100,101,4,5)
30
+
31
+ = head2 routine subbuf-rw
32
+
33
+ sub subbuf-rw(Buf:D $buf, $from, $length?)
34
+
35
+ Returns a writable reference to a part of a buffer. Similar to the C < subbuf-rw > method:
36
+
37
+ my Buf $b .= new(1,2,3);
38
+ subbuf-rw($b,2,1) = Buf.new(42);
39
+ dd $b; # OUTPUT: Buf $b = Buf.new(1,2,42)
40
+
14
41
= end pod
0 commit comments