CLEI Electronic Journal (Dec 1998)
Complete Traversals and their Implementation Using the Standard Template Library
Abstract
A complete traversal of a container C (such as a set) is informally described by the iteration scheme for x in C F(x,C) where F is a function that might possibly modify C by inserting new elements into it. We assume that the order in which the elements are treated is not relevant, as long as the iteration continues until F has been applied to all elements currently in C, including those F has inserted. Standard iteration mechanisms, such as the iterators provided in the C++ Standard Template Library (STL), do not directly support complete traversals. In this paper we present two approaches to complete traversals, both extending the STL framework, one by means of generic algorithms and the other by means of a container adaptor.