C ++ STL迭代器接口 [英] C++ STL iterator interface

查看:136
本文介绍了C ++ STL迭代器接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道STL库使用不同类型的迭代器遍历他的容器:输入,输出,向前,双向和随机访问。

I know that the STL library uses different kind of iterators to traverse his containers: input, output, forward, bidirectional and random access.

abstact经典c指针接口。因此,一个迭代器类必须有++,*运算符等等(作为一个指针)。

I also know that iterators abstact the classic c pointer interface. So an iterator class must have the ++, * operators and so on (to act like a pointer).

是在某种规范中编写的每种迭代器的接口?
这个接口只是一个在STL库中使用的约定,还是有一些类的层次结构,我应该从中扩展迭代器?

Is the interface for every kind of iterator written in some specification? Is this interface just a convention used in the STL library or is there some hierarchy of classes from which I should extend my iterators?

从我的理解,我应该'复制'STL库中的接口约定,以便能够使用我的迭代器。

From what I understand, I should just 'copy' the interface conventions followed in the STL library to be able to use my iterators with it.

推荐答案

可以从迭代器页面查找每个迭代器类别界面要求。

You can lookup each iterator category interface requirements from iterator page.

如前所述,人们通常不会从头开始实现整个迭代器接口,而是使用 boost :: iterator 库用于处理样板代码。

As already mentioned, people often don't bother implementing the entire iterator interfaces from scratch, but use boost::iterator library for taking care of the boilerplate code.

这篇关于C ++ STL迭代器接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆