您的位置:首页 > 其它

Design Principles for Collection and Enumerator Interfaces

2007-08-04 10:36 681 查看
Design Principles for Collection and Enumerator Interfaces

There are different design principles behind each type of interface:

A collection interface provides random access to a single item in the collection via the Item method, it lets clients discover how many items are in the collection via the Count property, and often allows clients to add and remove items.

An enumerator interface provides serial access to multiple items in a collection, it doesn't allow the client to discover how many items are in the collection (until the enumerator stops returning items), and it doesn't provide any way of adding or removing items.

Each type of interface plays a different role in providing access to the elements in a collection.

ATL provides the following classes to help you implement collections and enumerators.

ClassDescription
ICollectionOnSTLImplCollection interface implementation
IEnumOnSTLImplEnumerator interface implementation (assumes data stored in an STL-compatible container)
CComEnumImplEnumerator interface implementation (assumes data stored in an array)
CComEnumOnSTLEnumerator object implementation (uses IEnumOnSTLImpl)
CComEnumEnumerator object implementation (uses CComEnumImpl)
_CopyCopy policy class
_CopyInterfaceCopy policy class
CAdaptAdapter class (hides operator & allowing CComPtr, CComQIPtr, and CComBSTR to be stored in STL containers)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐