@@ -125,6 +125,7 @@ done(f::Filter, s) = s[1]
125
125
126
126
eltype {I} (:: Type{Filter{I}} ) = eltype (I)
127
127
iteratoreltype {F,I} (:: Type{Filter{F,I}} ) = iteratoreltype (I)
128
+ iteratorsize {T<:Filter} (:: Type{T} ) = SizeUnknown ()
128
129
129
130
# Rest -- iterate starting at the given state
130
131
@@ -140,6 +141,7 @@ done(i::Rest, st) = done(i.itr, st)
140
141
141
142
eltype {I} (:: Type{Rest{I}} ) = eltype (I)
142
143
iteratoreltype {I,S} (:: Type{Rest{I,S}} ) = iteratoreltype (I)
144
+ iteratorsize {T<:Rest} (:: Type{T} ) = SizeUnknown ()
143
145
144
146
# Count -- infinite counting
145
147
@@ -152,12 +154,13 @@ countfrom(start::Number) = Count(start, one(start))
152
154
countfrom () = Count (1 , 1 )
153
155
154
156
eltype {S} (:: Type{Count{S}} ) = S
155
- iteratoreltype {I<:Count} (:: Type{I} ) = HasEltype ()
156
157
157
158
start (it:: Count ) = it. start
158
159
next (it:: Count , state) = (state, state + it. step)
159
160
done (it:: Count , state) = false
160
161
162
+ iteratorsize {S} (:: Type{Count{S}} ) = IsInfinite ()
163
+
161
164
# Take -- iterate through the first n elements
162
165
163
166
immutable Take{I}
@@ -168,6 +171,7 @@ take(xs, n::Int) = Take(xs, n)
168
171
169
172
eltype {I} (:: Type{Take{I}} ) = eltype (I)
170
173
iteratoreltype {I} (:: Type{Take{I}} ) = iteratoreltype (I)
174
+ iteratorsize {T<:Take} (:: Type{T} ) = SizeUnknown () # TODO
171
175
172
176
start (it:: Take ) = (it. n, start (it. xs))
173
177
@@ -192,6 +196,7 @@ drop(xs, n::Int) = Drop(xs, n)
192
196
193
197
eltype {I} (:: Type{Drop{I}} ) = eltype (I)
194
198
iteratoreltype {I} (:: Type{Drop{I}} ) = iteratoreltype (I)
199
+ iteratorsize {T<:Drop} (:: Type{T} ) = SizeUnknown () # TODO
195
200
196
201
function start (it:: Drop )
197
202
xs_state = start (it. xs)
@@ -217,6 +222,7 @@ cycle(xs) = Cycle(xs)
217
222
218
223
eltype {I} (:: Type{Cycle{I}} ) = eltype (I)
219
224
iteratoreltype {I} (:: Type{Cycle{I}} ) = iteratoreltype (I)
225
+ iteratorsize {I} (:: Type{Cycle{I}} ) = IsInfinite ()
220
226
221
227
function start (it:: Cycle )
222
228
s = start (it. xs)
@@ -241,7 +247,7 @@ immutable Repeated{O}
241
247
end
242
248
repeated (x) = Repeated (x)
243
249
eltype {O} (:: Type{Repeated{O}} ) = O
244
- iteratoreltype {O} (:: Type{Repeated{O}} ) = HasEltype ()
250
+ iteratorsize {O} (:: Type{Repeated{O}} ) = IsInfinite ()
245
251
start (it:: Repeated ) = nothing
246
252
next (it:: Repeated , state) = (it. x, nothing )
247
253
done (it:: Repeated , state) = false
0 commit comments