IConstTraversableT Class

class IConstTraversableT

The IConstTraversableT templated interface is an abstract interface that enables polymorphic iteration. A polymorphic iterator is one which performs traversal without explicit knowledge of collection type. Instead, it uses the IConstTraversableT interface, which permits access to elements without exposing collection type. The IConstTraversableT interface can be mixed into any aggregate, thereby enabling polymorphic iteration for that aggregate. Therefore, this interface serves as a useful abstraction for an aggregate, because it can be returned, passed between functions, and used by polymorphic iterators without subjecting client code to unnecessary implementation-oriented dependencies.

The IConstTraversableT interface permits constant access to the aggregate only. If you need to pass an aggregate to a function, you can prevent that function from modifying collection content by passing it an IConstTraversableT interface. If the function requires read/write access to the collection, you can use the  ITraversableT interface instead.

Note: The IConstTraversableT interface has many member functions but only four are documented. The remaining members are meant to be used by the polymorphic iterators only.

Defined in: Traversable.h

Class Template Arguments

_Ty

The type of element contained in the aggregate that implements this interface.

Member functions include: AddRefReleaseemptysize

Class Members

virtual ULONG STDMETHODCALLTYPE AddRef() const

Increments the reference count on the aggregate.

virtual ULONG STDMETHODCALLTYPE Release() const

Decrements the reference count on the aggregate.

virtual bool empty() const

Returns true if the traversable object is empty.

virtual SEC_INT size() const

Returns the number of elements contained.