开发者

Implementing custom STL-like data structures

开发者 https://www.devze.com 2023-01-04 06:15 出处:网络
I have already implemented and tested the data structure and would now like to make it compatible with the collection of STL algorithms. Guidelines for implementing a custom iterator and the like. Spe

I have already implemented and tested the data structure and would now like to make it compatible with the collection of STL algorithms. Guidelines for implementing a custom iterator and the like. Specifically:

  • What is the minimum set of operations that must be supported? (e.g. ++, +=, ==, !=?)
  • Are there any properties of these operations that algorithms expect?

Ideally, these answers would be part of a bigger reference for implementing a STL-compatible data structure, but I'm n开发者_如何转开发ot sure that such a document exists.


You should consult the SGI STL documentation. It has detailed requirements for each of the STL components, including containers and iterators.

Effectively, for iterators, there are various types--input iterators, output iterators, forward iterators, bidirectional iterators, and random-access iterators. The specification for each algorithm indicates the type of iterator required.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号