O'Reilly logo

Extended STL, Volume 1: Collections and Iterators by Matthew Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 23. The Fibonacci Sequence

 

If liberty means anything at all, it means the right to tell people what they do not want to hear.

 
 --George Orwell
 

Subtlety chases the obvious in a never-ending spiral and never quite catches it.

 
 --Nero Wolfe

Introduction

Those who enjoy mathematical elegance may share my appreciation of the Fibonacci sequence and its associated relationship, the Golden Ratio. In this chapter we’re going to look at how we might represent this mathematical sequence as a collection, in the form of an STL sequence class, and 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.

Unlike the other STL extensions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required