课程: Python: Design Patterns (2021)
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Iterator
- The iterator pattern allows a client to have sequential access to the elements of an aggregate object without exposing its underlying structure. The problem is that some programmers overcrowd the traversal interfaces of an aggregate object for every possible way of iteration. We'll be building our own iterator that takes advantage of a built in Python iterator called zip. The iterator goes through a list of German counting words. It will iterate only up to a certain point based on client input. The iterator isolates access and traversal features from the aggregate object. It also provides an interface for accessing the elements of an aggregate object. An iterator keeps track of the objects being traversed. Our solution is to make the aggregate object create an iterator for a client. The composite design pattern is related to the iterator pattern.
内容
-
-
-
-
-
-
(已锁定)
Observer1 分钟 5 秒
-
(已锁定)
Observer example6 分钟 22 秒
-
(已锁定)
Visitor56 秒
-
(已锁定)
Visitor example6 分钟 42 秒
-
(已锁定)
Iterator1 分钟 15 秒
-
(已锁定)
Iterator example4 分钟 32 秒
-
(已锁定)
Strategy40 秒
-
(已锁定)
Strategy example5 分钟 44 秒
-
(已锁定)
Chain of responsibility1 分钟 4 秒
-
(已锁定)
Chain of responsibility example5 分钟 57 秒
-
(已锁定)
-
-