Abstract
Motivated by a wish to sort an array A while simultaneously permuting another array B, iteration over array pairs (A,B) is considered.
Traditional solutions to this problem require an adaption of either the algorithm or of the data structure. The generic programming approach described in this paper involves the construction of an iterator adaptor: an iterator pair. The different approaches are implemented in C++ and compared with respect to flexibility and performance.
Our design is also compared with another iterator-based design. When examining our solution, we identify the relationship between a reference type and a value type as an independent abstraction. We find that a valid “reference type” to a value type T is not necessarily T&. The reference pair developed in this paper serves as an example of a reference type which refers to a standard value pair without being a standard reference.
Our understanding of the relationships between iterator pairs, value pairs, and reference pairs, makes our design simpler than the alternative. It is argued that a recognition of these relationships is useful in many other generic programming contexts as well.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Comsol homepage, http://www.comsol.com/
Boost MPL, homepage: http://www.boost.org/libs/mpl/doc/index.html
Williams, A.: Pairing off iterators. Overload (2001), Avaliable at: http://web.onetel.com/~anthony_w/cplusplus/pair_iterators.pdf (2005-04-07)
The C++ Standard, Incorporating Technical Corrigendum No. 1.2 edn. John Wiley & Sons, Ltd. (2003)
Abrahams, D., Siek, J., Witt, T.: New iterator concepts (2003), http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1550.htm
Musser, D., Saini, A.: STL Tutorial and Reference Guide. Addison-Wesley, Reading (1996)
C++ standard library active issues list, revision 35 (2005), http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html (2005-03-04)
Alexandrescu, A.: Modern C++ Design: Generic Programming and Design Patterns Applied. Addison-Wesley, Reading (2001)
Musser, D.: Introspective sorting and selection algorithms. Software–Practice and Experience 8, 983–993 (1997)
Abrahams, D., Gurtovoy, A.: C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and beyond. Addison-Wesley, Reading (2005)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2005 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Åhlander, K. (2005). Sorting Out the Relationships Between Pairs of Iterators, Values, and References. In: Glück, R., Lowry, M. (eds) Generative Programming and Component Engineering. GPCE 2005. Lecture Notes in Computer Science, vol 3676. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11561347_23
Download citation
DOI: https://doi.org/10.1007/11561347_23
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-29138-1
Online ISBN: 978-3-540-31977-1
eBook Packages: Computer ScienceComputer Science (R0)