Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet205/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   201   202   203   204   205   206   207   208   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
303 

A variant of this class could define Traverse to return ifat least one item 
satisfies the test.
6
Known Uses 
Iterators are common in object-oriented systems. Most collectionclass libraries 
offer iterators in one form or another. 
Here's an example from the Booch components [Boo94], apopular collection class 
library. It provides both a fixed size(bounded) and dynamically growing (unbounded) 
implementation of aqueue. The queue interface is defined by an abstract Queue 
class. Tosupport polymorphic iteration over the different queueimplementations, 
the queue iterator is implemented in the terms of theabstract Queue class interface. 
This variation has the advantage thatyou don't need a factory method to ask the 
queue implementations fortheir appropriate iterator. However, it requires the 
interface of theabstract Queue class to be powerful enough to implement the 
iteratorefficiently. 
Iterators don't have to be defined as explicitly in Smalltalk. Thestandard 
collection classes (Bag, Set, Dictionary, OrderedCollection,String, etc.) define 
an internal iterator method do:, whichtakes a block (i.e., closure) as an argument. 
Each element in thecollection is bound to the local variable in the block; then 
the blockis executed. Smalltalk also includes a set of Stream classes thatsupport 
an iterator-like interface. ReadStream is essentially anIterator, and it can act 
as an external iterator for all thesequential collections. There are no standard 
external iterators fornonsequential collections such as Set and Dictionary. 
Polymorphic iterators and the cleanup Proxy described earlier areprovided by the 
ET++ container classes [WGM88]. The Unidrawgraphical editing framework classes 
use cursor-basediterators [VL90]. 
ObjectWindows 2.0 [Bor94] provides a class hierarchy ofiterators for containers. 
You can iterate over different containertypes in the same way. The ObjectWindow 
iteration syntax relies onoverloading the postincrement operator ++ to advance 
theiteration. 

Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   201   202   203   204   205   206   207   208   ...   288




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish