function mgcoarraylistiterator::hasNext
compile_opt strictarr
return, self.pos lt self.arraylist->count()
end
function mgcoarraylistiterator::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 mgcoarraylistiterator::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 mgcoarraylistiterator::cleanup
compile_opt strictarr
self->MGcoAbstractIterator::cleanup
end
function mgcoarraylistiterator::init, arraylist
compile_opt strictarr
if (~self->mgcoabstractiterator::init()) then return, 0
self.arraylist = arraylist
self.arraylist->getProperty, version=version
self.version = version
self.pos = 0
return, 1B
end
pro mgcoarraylistiterator__define
compile_opt strictarr
define = { MGcoArrayListiterator, inherits MGcoAbstractIterator, $
arraylist: obj_new(), $
pos: 0L $
}
end