Represent the Fibonacci Sequence as a collection in the form of an STL sequence class
Source: Addison Wesley Professional
Anyone who appreciates mathematical elegance will appreciate the Fibonacci sequence and its associated relationship, the Golden Ratio. In this chapter download from Extended STL: Collections and Iterators, Volume 1, examine how this mathematical sequence can be represented as a collection in the form of a Standard Template Library (STL) sequence class, then consider whether it might be better represented as an iterator, before finally coming back to seeing how a range-limited sequence is the most discoverable representation. The chapter covers issues related to implementing an unbounded (infinite) notional collection, highlighting the imperfect fit between such collections and the strict finitude of C++'s integral types and the assumed boundedness of STL iterator pairs.
Title: Extended STL: Collections and Iterators, Volume 1
Author: Matthew Wilson
Publisher: Addison Wesley Professional
Chapter 23: The Fibonacci Sequence
ISBN: 0-321-30550-7; Copyright 2007, Addison Wesley Professional. All rights reserved.
Used with permission from the publisher. Available from booksellers or direct from Addison Wesley Professional