mirror of
https://github.com/rjNemo/design-patterns
synced 2026-06-06 02:26:40 +00:00
doc: update tocs
This commit is contained in:
parent
c66084e516
commit
7534ffc639
3 changed files with 3 additions and 1 deletions
|
|
@ -43,3 +43,4 @@ and divided into three groups.
|
|||
|
||||
- [Chain of Responsibility](behavioral/chain_responsibility/README.md)
|
||||
- [Command](behavioral/command/README.md)
|
||||
- [Iterator](behavioral/iterator/README.md)
|
||||
|
|
|
|||
|
|
@ -6,3 +6,4 @@ Behavioral design patterns are concerned with algorithms and the assignment of r
|
|||
|
||||
- [Chain of Responsibility](chain_responsibility/README.md)
|
||||
- [Command](command/README.md)
|
||||
- [Iterator](iterator/README.md)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ The main idea of the Iterator pattern is to extract the traversal behavior of a
|
|||
|
||||
In addition to implementing the algorithm itself, an iterator object encapsulates all of the traversal details, such as the current position and how many elements are left till the end. Because of this, several iterators can go through the same collection at the same time, independently of each other.
|
||||
|
||||
Usually, iterators provide one primary method for fetching elements of the collection. The client can keep running this method until it doesn’t return anything, which means that the iterator has traversed all of the elements.
|
||||
Usually, iterators provide one primary method for fetching elements of the collection. The client can keep running this method until it doesn't return anything, which means that the iterator has traversed all of the elements.
|
||||
|
||||
All iterators must implement the same interface. This makes the client code compatible with any collection type or any traversal algorithm as long as there’s a proper iterator. If you need a special way to traverse a collection, you just create a new iterator class, without having to change the collection or the client.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue