- Mastering the C++17 STL
- Arthur O'Dwyer
- 181字
- 2021-07-08 10:20:22
Summary
In this chapter, we've learned that traversal is one of the most fundamental things you can do with a data structure. However, raw pointers alone are insufficient for traversing complicated structures: applying ++ to a raw pointer often doesn't "go on to the next item" in the intended way.
The C++ Standard Template Library provides the concept of iterator as a generalization of raw pointers. Two iterators define a range of data. That range might be only part of the contents of a container; or it might be unbacked by any memory at all, as we saw with getc_iterator and putc_iterator. Some of the properties of an iterator type are encoded in its iterator category--input, output, forward, bidirectional, or random-access--for the benefit of function templates that can use faster algorithms on certain categories of iterators.
If you're defining your own container type, you'll need to define your own iterator types as well--both const and non-const versions. Templates are a handy way to do that. When implementing your own iterator types, avoid the deprecated std::iterator, but consider boost::iterator_facade.
- TypeScript Blueprints
- Python for Secret Agents:Volume II
- Cocos2d-x游戲開發:手把手教你Lua語言的編程方法
- Raspberry Pi for Secret Agents(Third Edition)
- Reactive Programming With Java 9
- 微信小程序開發解析
- 深入理解Elasticsearch(原書第3版)
- Android項目實戰:手機安全衛士開發案例解析
- Arduino可穿戴設備開發
- SQL Server 入門很輕松(微課超值版)
- C# 7.1 and .NET Core 2.0:Modern Cross-Platform Development(Third Edition)
- 測試工程師Python開發實戰
- 趣學數據結構
- Learning GraphQL and Relay
- Python 3.6從入門到精通(視頻教學版)