mercredi 13 janvier 2016

Purpose of the iterator-pattern. Have I understood it right?

I have recently tried to understand the so-called Iterator pattern.

Think if have understood it's purpose but I'm still not sure. So please correct me concerning this:

The purpose of the iterator pattern is to abstract away the underlying structure in which the data are kept. Data-structure can be an array, a tree, a list ...

It's important methods are hasNext() (returns an object), next() (returns a boolean) and remove().

The methods are implemented in a way which is appropriate way for the used data-structure. So the developer who uses a iterator implementing class don't have to care. Just uses the provided methods which are the same for every iterator implementing class.

Have I get it right?

Aucun commentaire:

Enregistrer un commentaire