-
Book Overview & Buying
-
Table Of Contents
D Cookbook
By :
Input ranges are D's improvement to the iterators of C++ that are safer, potentially more efficient, and can also generate their own data. Here, we'll create an input range that generates numbers in a Fibonacci sequence to see how it can be done and briefly explore how well it integrates with std.algorithm automatically.
Let's execute the following steps to create an input range that generates numbers in a Fibonacci sequence:
Create a struct with, minimally, the three core input range members: the properties front, the properties of empty, and the function popFront. It should also hold whatever state is necessary for iteration with successive calls to popFront.
Add all other functionality as possible without breaking the complexity guarantee. Our Fibonacci generator can also implement a simple save property, so we will add it, upgrading it to a forward range.
Test it with static assert for the interface you need and perform unit tests.
Write a helper method...
Change the font size
Change margin width
Change background colour