function mgarraylistiterator::hasNext
compile_opt strictarr
return, self.pos lt self.arraylist->count()
end
function mgarraylistiterator::next
compile_opt strictarr
on_error, 2
if (self.pos ge self.arraylist->count()) then begin
message, 'No more elements'
endif
self.arraylist->getProperty, version=version
if (self.version ne version) then begin
message, 'Underlying collection has changed'
endif
return, self.arraylist->get(position=self.pos++)
end
pro mgarraylistiterator::remove
compile_opt strictarr
on_error, 2
self.arraylist->getProperty, version=version
if (self.version ne version) then begin
message, 'Underlying collection has changed'
endif
if (self.pos le 0) then begin
message, 'No element to remove'
endif
self.arraylist->remove, position=--self.pos
self.arraylist->getProperty, version=version
self.version = version
end
pro mgarraylistiterator::cleanup
compile_opt strictarr
end
function mgarraylistiterator::init, arraylist
compile_opt strictarr
self.arraylist = arraylist
self.arraylist->getProperty, version=version
self.version = version
self.pos = 0
return, 1B
end
pro mgarraylistiterator__define
compile_opt strictarr
define = { mgarraylistiterator, inherits mgabstractiterator, $
arraylist : obj_new(), $
pos : 0L $
}
end