You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 09_iterators.html
+44-46Lines changed: 44 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -140,7 +140,7 @@ <h2>History of iterators</h2>
140
140
and for all.</p>
141
141
142
142
<p>Let me tell you a little about them.
143
-
Anybody who programs in C++ is forced to use vector
143
+
Anybody who programs in C++ is forced to use <code>std::vector</code>
144
144
and those have iterators.
145
145
But, there are lots of people who do not quite understand what they are,
146
146
partially because iterators are called iterators.
@@ -157,12 +157,8 @@ <h2>History of iterators</h2>
157
157
But, many people at <ahref="https://en.wikipedia.org/wiki/Carnegie_Mellon_University">CMU</a> got tenure because of it.
158
158
It has some interesting ideas, including the idea of a generator.
159
159
For those of you who know <ahref="https://en.wikipedia.org/wiki/Python_(programming_language)">Python</a>, it is like an iterator in Python<supid="fnref:1"><ahref="#fn:1" rel="footnote">1</a></sup>.
160
-
Barbara Liskov said, wouldn’t it be nice to write:</p>
161
-
162
-
<pre><code>for x in thing
163
-
</code></pre>
164
-
165
-
<p>and iterators allow you to do that<supid="fnref:2"><ahref="#fn:2" rel="footnote">2</a></sup>.
160
+
Barbara Liskov said, “wouldn’t it be nice to write something like: <code>for x in thing</code>”.
161
+
Iterators allow you to do that<supid="fnref:2"><ahref="#fn:2" rel="footnote">2</a></sup>.
166
162
It is like a generator in Alphard.
167
163
It is a procedure which returns multiple values, one by one.
168
164
It’s a procedural abstraction.
@@ -173,12 +169,12 @@ <h2>History of iterators</h2>
173
169
<p>At the same time, I was working on how to do algorithms and I
174
170
introduced the notion of position.
175
171
A better name is coordinate, the name which Paul and I use
176
-
in our book “Elements of Programming”<supid="fnref:3"><ahref="#fn:3" rel="footnote">3</a></sup>.
172
+
in our book “Elements of Programming”.
177
173
A coordinate is some way of indicating where in the data structure you are.
178
174
It is not a control structure, it’s just the pointer into a data structure,
179
175
or generalized notion of a coordinate.
180
176
It is something which allows me to navigate through the data structure in a
@@ -532,7 +526,7 @@ <h3>Everything on a computer is totally ordered</h3>
532
526
but it establishes a total ordering.
533
527
A total ordering does not have to be topologically induced by the traversal.</p>
534
528
535
-
<p><strong>Exercise:</strong>extend the iterator to linked iterator
529
+
<p><strong>Exercise:</strong>Extend the iterator to linked iterator
536
530
so we can assign the next on a node.
537
531
Specifically we want to be able to modify the successor of
538
532
an iterator.</p>
@@ -581,9 +575,13 @@ <h2>Code</h2>
581
575
<liid="fn:2">
582
576
See this <ahref="http://web.mit.edu/ghudson/info/iterators">brief description of CLU iterators</a>.<ahref="#fnref:2" rev="footnote">↩</a></li>
583
577
<liid="fn:3">
584
-
See chapter 7 of “Elements of Programming” on coordinate structures.<ahref="#fnref:3" rev="footnote">↩</a></li>
578
+
See chapter 7 of “Elements of Programming” on coordinate structures.
579
+
An interesting discussion on the general idea of “coordinatisation”
580
+
is found in chapter 1 of “Basic Notions of Algebra” by Shafarevich.<ahref="#fnref:3" rev="footnote">↩</a></li>
585
581
<liid="fn:4">
586
-
<ahref="https://www.boost.org/">Boost</a> is a popular collection of C++ libraries generally accepted as the next tool to reach for beyond the standard library.
582
+
<ahref="https://www.boost.org/">Boost</a> is a popular collection of C++ libraries, covering a wide range of uses,
583
+
generally accepted as the next tool to reach for beyond the standard library.
584
+
Many standard library features, such as smart pointers, were initially developed in Boost.
587
585
Alex speaks positively of some parts (see <ahref="http://stepanovpapers.com/siekforeword.pdf">his foreword</a> for “The Boost Graph Library”), but others he is more critical of.<ahref="#fnref:4" rev="footnote">↩</a></li>
588
586
<liid="fn:5">
589
587
Some algorithms can be implemented more efficiently for certain
0 commit comments