Skip to content

Commit cce1d92

Browse files
committed
Added usage statements to Types Iterable.pod through Lock.pod
1 parent b94de0c commit cce1d92

File tree

5 files changed

+342
-2
lines changed

5 files changed

+342
-2
lines changed

lib/Type/Iterable.pod

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Its important aspect is a method stub for C<iterator>.
1919
2020
=head2 method iterator
2121
22+
Defined as:
23+
2224
method iterator() returns Iterator:D { ... }
2325
2426
Method stub that ensures all classes doing the C<Iteraable> role have a method
@@ -28,8 +30,14 @@ It is supposed to return an L<Iterator|/type/Iterator>.
2830
2931
=head2 method flat
3032
33+
Defined as:
34+
3135
method flat() return Iterable
3236
37+
Usage:
38+
39+
ITERABLE.flat
40+
3341
Returns another L<Iterable> that flattens out all iterables that the first one
3442
returns.
3543
@@ -48,25 +56,43 @@ returns C<("a", "b", "c", "d")>, but it does not flatten itemized sublists:
4856
4957
=head2 method lazy
5058
59+
Defined as:
60+
5161
method lazy() returns Iterable
5262
63+
Usage:
64+
65+
ITERABLE.lazy
66+
5367
Returns a lazy iterable wrapping the invocant.
5468
5569
=head2 method hyper
5670
71+
Defined as:
72+
5773
method hyper(Int(Cool) :$batch = 64, Int(Cool) :$degree = 4)
5874
returns Iterable
5975
76+
Usage:
77+
78+
ITERABLE.hyper(BATCH?, DEGREE?)
79+
6080
Returns another Iterable that is potentially iterated in parallel, with a
6181
given batch size and degree of parallelism.
6282
6383
The order of elements are preserved.
6484
6585
=head2 method race
6686
87+
Defined as:
88+
6789
method race(Int(Cool) :$batch = 64, Int(Cool) :$degree = 4)
6890
returns Iterable
6991
92+
Usage:
93+
94+
ITERABLE.race(BATCH?, DEGREE?)
95+
7096
Returns another Iterable that is potentially iterated in parallel, with a
7197
given batch size and degree of parallelism.
7298

lib/Type/Iterator.pod

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ iterator API. Any other behavior is undefined and implementation dependent.
2929
3030
=head2 method pull-one
3131
32+
Defined as:
33+
3234
method pull-one(Iterator:D:) returns Mu { ... }
3335
36+
Usage:
37+
38+
ITERATOR.pull-one
39+
3440
This method stub ensures that classes implementing the C<Iterator> role
3541
provide a method named C<pull-one>.
3642
@@ -39,8 +45,14 @@ the sentenial value C<IterationEnd> if no more elements are available.
3945
4046
=head2 method push-exactly
4147
48+
Defined as:
49+
4250
method push-exactly(Iterator:D: $target, int $count) returns Mu
4351
52+
Usage:
53+
54+
ITERATOR.push-exactly(TARGET, COUNT)
55+
4456
Produces C<$count> elements, and for each of them, calls
4557
C<$target.push($value)>.
4658
@@ -50,8 +62,14 @@ C<$count>.
5062
5163
=head2 method push-at-least
5264
65+
Defined as:
66+
5367
method push-at-least(Iterator:D: $target, int $count) returns Mu
5468
69+
Usage:
70+
71+
ITERATOR.push-at-least(TARGET, COUNT)
72+
5573
Produces at least C<$count> elements, and for each of them, calls
5674
C<$target.push($value)>.
5775
@@ -65,17 +83,29 @@ produce more elements to achieve better performance.
6583
6684
=head2 method push-all
6785
86+
Defined as:
87+
6888
method push-all(Iterator:D: $target)
6989
90+
Usage:
91+
92+
ITERATOR.push-all(TARGET)
93+
7094
Produces all elements from the iterator and pushes them to C<$target>.
7195
7296
The fallback is implemented in terms of repeated C<push-at-least> with a large
7397
C<$count>.
7498
7599
=head2 method push-until-lazy
76100
101+
Defined as:
102+
77103
method push-until-lazy(Iterator:D: $target) returns Mu
78104
105+
Usage:
106+
107+
ITERATOR.push-until-lazy(TARGET)
108+
79109
Produces values until it considers itself to be lazy, and pushes them onto
80110
C<$target>.
81111
@@ -84,8 +114,14 @@ which might be lazy, while others aren't.
84114
85115
=head2 method is-lazy
86116
117+
Defined as:
118+
87119
method is-lazy(Iterator:D:) returns Bool:D
88120
121+
Usage:
122+
123+
ITERATOR.is-lazy
124+
89125
Returns C<True> for iterators that consider themselves lazy, and C<False>
90126
otherwise.
91127
@@ -94,16 +130,28 @@ return C<True> here, for example C<(1..6).roll(*)>.
94130
95131
=head2 method count-only
96132
133+
Defined as:
134+
97135
method count-only(Iterator:D:) returns int
98136
137+
Usage:
138+
139+
ITERATOR.count-only
140+
99141
Produces and discards all elements until it returns the end of the iteration,
100142
and returns the number of elements produced. This is useful to reduce memory
101143
usage in scenarios such as C<open($file).lines.elems>.
102144
103145
=head2 method sink-all
104146
147+
Defined as:
148+
105149
method sink-all(Iterator:D:)
106150
151+
Usage:
152+
153+
ITERATOR.sink-all
154+
107155
Exhausts the iterator (while discarding generated elements) purely for the
108156
side effects of the iteraton.
109157

lib/Type/Label.pod

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,26 @@ Those label are objects of type C<Label>.
2525
2626
=head2 method next
2727
28+
Defined as:
29+
2830
method next(Label:)
2931
32+
Usage:
33+
34+
next LABEL
35+
3036
Begin the next iteration of the loop associated with the label.
3137
3238
=head2 method last
3339
40+
Defined as:
41+
3442
method last(Label:)
3543
44+
Usage:
45+
46+
last LABEL
47+
3648
Terminate the execution of the loop associated with the label.
3749
3850
=end pod

0 commit comments

Comments
 (0)