Design Patterns : Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet278/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   274   275   276   277   278   279   280   281   ...   288
Bog'liq
GOF Design Patterns

Stack Interface 
Item& Top() const 
returns the top element (when the List is viewed as a stack). 
void Push(const Item&) 
pushes the element onto the stack. 
Item& Pop() 
pops the top element from the stack. 
Iterator 
Iterator is an abstract class that defines a traversalinterface for aggregates. 
template  
class Iterator { 
public: 
virtual void First() = 0; 
virtual void Next() = 0; 
virtual bool IsDone() const = 0; 
virtual Item CurrentItem() const = 0;
protected: 
Iterator(); 
}; 
The operations do the following: 
virtual void First() 
positions the iterator to the first object in the aggregate. 
virtual void Next() 
positions the iterator to the next object in the sequence. 
virtual bool IsDone() const 
returns true when there are no more objects in the sequence. 
virtual Item CurrentItem() const 


Design Patterns: Elements of Reusable Object-Oriented Software 
413 
returns the object at the current position in the sequence. 
ListIterator 
ListIterator implements the Iterator interfaceto traverse List objects. Its 
constructor takes a list to traverse asan argument. 
template  
class ListIterator : public Iterator
public: 
ListIterator(const List* aList); 
virtual void First(); 
virtual void Next(); 
virtual bool IsDone() const; 
virtual Item CurrentItem() const; 
}; 
Point 
Point represents a point in a two-dimensional Cartesiancoordinate space. Point 
supports some minimal vector arithmetic.The coordinates of a Point are defined 
as 
typedef float Coord
Point's operations are self-explanatory. 
class Point { 
public: 
static const Point Zero
Point(Coord x = 0.0, Coord y = 0.0);
Coord X() const; void X(Coord x); 
Coord Y() const; void Y(Coord y); 
friend Point operator+(const Point&, const Point&); 
friend Point operator-(const Point&, const Point&); 
friend Point operator*(const Point&, const Point&); 
friend Point operator/(const Point&, const Point&); 
Point& operator+=(const Point&); 



Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   274   275   276   277   278   279   280   281   ...   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