2012-07-29 06:59:54 +02:00
|
|
|
module Puppet
|
|
|
|
module Util
|
|
|
|
class ExternalIterator
|
|
|
|
def initialize(coll)
|
|
|
|
@coll = coll
|
2012-08-17 13:48:28 +02:00
|
|
|
@cur_index = -1
|
2012-07-29 06:59:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def next
|
|
|
|
@cur_index = @cur_index + 1
|
|
|
|
item_at(@cur_index)
|
|
|
|
end
|
|
|
|
|
|
|
|
def peek
|
|
|
|
item_at(@cur_index + 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def item_at(index)
|
2012-08-17 13:48:28 +02:00
|
|
|
if @coll.length > index
|
|
|
|
[@coll[index], index]
|
|
|
|
else
|
|
|
|
[nil, nil]
|
|
|
|
end
|
2012-07-29 06:59:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|