File: iterator_concept.htm

package info (click to toggle)
boost 1.34.1-14
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 116,412 kB
  • ctags: 259,566
  • sloc: cpp: 642,395; xml: 56,450; python: 17,612; ansic: 14,520; sh: 2,265; yacc: 858; perl: 481; makefile: 478; lex: 94; sql: 74; csh: 6
file content (1158 lines) | stat: -rw-r--r-- 32,511 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<link href="ublas.css" type="text/css" />
<title>Iterator Concepts</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />
Iterator Concepts</h1>
<p>An Iterator is a restricted pointer-like object pointing into a
vector or matrix container.</p>
<h2><a name="indexed_bidirectional_iterator" id=
"indexed_bidirectional_iterator"></a>Indexed Bidirectional Iterator</h2>
<h4>Description</h4>
<p>An Indexed Bidirectional Iterator is an iterator of a container
that can be dereferenced, incremented, decremented and carries
index information.</p>
<h4>Refinement of</h4>
<p>Assignable, Equality Comparable, Default Constructible.</p>
<h4>Associated types</h4>
<table border="1" summary="associated types">
<tbody>
<tr>
<td>Value type</td>
<td>The type of the value obtained by dereferencing a Indexed
Bidirectional Iterator</td>
</tr>
<tr>
<td>Container type</td>
<td>The type of the container a Indexed Bidirectional Iterator
points into.</td>
</tr>
</tbody>
</table>
<h4>Notation</h4>
<table border="0" summary="notation">
<tbody>
<tr>
<td><code>I</code></td>
<td>A type that is a model of Indexed Bidirectional Iterator</td>
</tr>
<tr>
<td><code>T</code></td>
<td>The value type of <code>I</code></td>
</tr>
<tr>
<td><code>C</code></td>
<td>The container type of <code>I</code></td>
</tr>
<tr>
<td><code>it</code>, <code>itt, it1</code>, <code>it2</code></td>
<td>Objects of type <code>I</code></td>
</tr>
<tr>
<td><code>t</code></td>
<td>Object of type <code>T</code></td>
</tr>
<tr>
<td><code>c</code></td>
<td>Object of type <code>C</code></td>
</tr>
</tbody>
</table>
<h4>Definitions</h4>
<p>A Indexed Bidirectional Iterator may be <i>mutable</i>, meaning
that the values referred to by objects of that type may be
modified, or <i>constant</i> , meaning that they may not. If an
iterator type is mutable, this implies that its value type is a
model of Assignable; the converse, though, is not necessarily
true.</p>
<p>A Indexed Bidirectional Iterator may have a <i>singular</i>
value, meaning that the results of most operations, including
comparison for equality, are undefined. The only operation that is
guaranteed to be supported is assigning a nonsingular iterator to a
singular iterator.</p>
<p>A Indexed Bidirectional Iterator may have a
<i>dereferenceable</i> value, meaning that dereferencing it yields
a well-defined value. Dereferenceable iterators are always
nonsingular, but the converse is not true.</p>
<p>An Indexed Bidirectional Iterator is <i>past-the-end</i> if it
points beyond the last element of a container. Past-the-end values
are nonsingular and nondereferenceable.</p>
<h4>Valid expressions</h4>
<p>In addition to the expressions defined for Assignable, Equality
Comparable and Default Constructible, the following expressions
must be valid.</p>
<table border="1" summary="expressions">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Type requirements</th>
<th>Return type</th>
</tr>
<tr>
<td>Default constructor</td>
<td><code>I it</code></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Dereference</td>
<td><code>*it</code></td>
<td>&nbsp;</td>
<td>Convertible to <code>T</code>.</td>
</tr>
<tr>
<td>Dereference assignment</td>
<td><code>*it = t</code></td>
<td><code>I</code> is mutable.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Member access</td>
<td><code>it-&gt;m</code></td>
<td><code>T</code> is a type for which <code>t.m</code> is
defined.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Preincrement</td>
<td><code>++ it</code></td>
<td>&nbsp;</td>
<td><code>I &amp;</code></td>
</tr>
<tr>
<td>Postincrement</td>
<td><code>it ++</code></td>
<td>&nbsp;</td>
<td><code>I</code></td>
</tr>
<tr>
<td>Predecrement</td>
<td><code>-- it</code></td>
<td>&nbsp;</td>
<td><code>I &amp;</code></td>
</tr>
<tr>
<td>Postdecrement</td>
<td><code>it --</code></td>
<td>&nbsp;</td>
<td><code>I</code></td>
</tr>
<tr>
<td>Index</td>
<td><code>it.index ()</code></td>
<td>&nbsp;</td>
<td><code>C::size_type</code></td>
</tr>
</tbody>
</table>
<h4>Expression Semantics</h4>
<p>Semantics of an expression is defined only where it differs
from, or is not defined in, Assignable, Equality Comparable and
Default Constructible.</p>
<table border="1" summary="semantics">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Precondition</th>
<th>Semantics</th>
<th>Postcondition</th>
</tr>
<tr>
<td>Default constructor</td>
<td><code>I it</code></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><code>it</code> is singular.</td>
</tr>
<tr>
<td>Dereference</td>
<td><code>*it</code></td>
<td><code>it</code> is dereferenceable.</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Dereference assignment</td>
<td><code>*it = t</code></td>
<td>Same as for <code>*it</code>.</td>
<td>&nbsp;</td>
<td><code>*it</code> is a copy of t.</td>
</tr>
<tr>
<td>Member access</td>
<td><code>it-&gt;m</code></td>
<td><code>it</code> is dereferenceable.</td>
<td>Equivalent to <code>(*it).m</code></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Preincrement</td>
<td><code>++ it</code></td>
<td><code>it</code> is dereferenceable.</td>
<td><code>it</code> is modified to point to the next element.</td>
<td><code>it</code> is dereferenceable or past-the-end.
<code><br />
&amp;it == &amp;++ it</code>.<br />
If <code>it1 == it2</code>,<br />
then <code>++ it1 == ++ it2</code>.</td>
</tr>
<tr>
<td>Postincrement</td>
<td><code>it ++</code></td>
<td>Same as for <code>++ it</code>.</td>
<td>Equivalent to<br />
<code>{<br />
&nbsp;I itt = it;<br />
&nbsp;++ it;<br />
&nbsp;return itt;<br />
}</code></td>
<td><code>it</code> is dereferenceable or past-the-end.</td>
</tr>
<tr>
<td>Predecrement</td>
<td><code>-- it</code></td>
<td><code>it</code> is dereferenceable or past-the-end.<br />
There exists a dereferenceable iterator <code>itt</code> such that
<code>it == ++ itt</code>.</td>
<td><code>it</code> is modified to point to the previous
element.</td>
<td><code>it</code> is dereferenceable.<br />
<code>&amp;it = &amp;-- it</code>.<br />
If <code>it1 == it2</code>,<br />
then <code>-- it1 == -- it2</code>.<br />
If <code>it2</code> is dereferenceable and <code>it1 ==
++it2</code>,<br />
then <code>--it1 == it2</code>.</td>
</tr>
<tr>
<td>Postdecrement</td>
<td><code>it --</code></td>
<td>Same as for -- <code>it</code>.</td>
<td>Equivalent to<br />
<code>{<br />
&nbsp;I itt = it;<br />
&nbsp;-- it;<br />
&nbsp;return itt;<br />
}</code></td>
<td><code>it</code> is dereferenceable.&nbsp;</td>
</tr>
<tr>
<td>Index</td>
<td><code>it.index ()</code></td>
<td><code>it</code> is dereferenceable.</td>
<td><code>it.index () &gt;= 0</code><br />
and<br />
<code>it.index () &lt; it ().size ()</code></td>
<td>If <code>it1 == it2</code>,<br />
then <code>it1.index () == it2</code>.<code>index ()</code>.<br />
If <code>it1 == it2</code>,<br />
then <code>it1.index () &lt; (++ it2</code>).<code>index
()</code>.<br />
If <code>it1 == it2</code>,<br />
then <code>it1.index () &gt; (-- it2</code>).<code>index
()</code>.</td>
</tr>
</tbody>
</table>
<h4>Complexity guarantees</h4>
<p>The complexity of operations on indexed bidirectional iterators
is guaranteed to be amortized constant time.</p>
<h4>Invariants</h4>
<table border="1" summary="invariants">
<tbody>
<tr>
<td>Identity</td>
<td><code>it1 == it2</code> if and only if <code>&amp;*it1 ==
&amp;*it2</code>.</td>
</tr>
<tr>
<td>Symmetry of increment and decrement</td>
<td>If <code>it</code> is dereferenceable, then <code>++ it;
--it;</code> is a null operation. Similarly, <code>-- it; ++
it;</code> is a null operation.</td>
</tr>
<tr>
<td>Relation between iterator index and container element
operator</td>
<td>If <code>it</code> is dereferenceable, <code>*it == it ()
(it.index ())</code>.</td>
</tr>
</tbody>
</table>
<h4>Models</h4>
<ul>
<li><code>sparse_vector::iterator</code></li>
</ul>
<h2><a name="indexed_random_access_iterator" id=
"indexed_random_access_iterator"></a>Indexed Random Access Iterator</h2>
<h4>Description</h4>
<p>An Indexed Random Access Iterator is an iterator of a container
that can be dereferenced, moved forward, moved backward and carries
index information.</p>
<h4>Refinement of</h4>
<p>LessThanComparable, <a href=
"#indexed_bidirectional_iterator">Indexed Bidirectional
Iterator</a> .</p>
<h4>Associated types</h4>
<table border="1" summary="associated types">
<tbody>
<tr>
<td>Value type</td>
<td>The type of the value obtained by dereferencing a Indexed
Random Access Iterator</td>
</tr>
<tr>
<td>Container type</td>
<td>The type of the container a Indexed Random Access Iterator
points into.</td>
</tr>
</tbody>
</table>
<h4>Notation</h4>
<table border="0" summary="notation">
<tbody>
<tr>
<td><code>I</code></td>
<td>A type that is a model of Indexed Random Access Iterator</td>
</tr>
<tr>
<td><code>T</code></td>
<td>The value type of <code>I</code></td>
</tr>
<tr>
<td><code>C</code></td>
<td>The container type of <code>I</code></td>
</tr>
<tr>
<td><code>it</code>, <code>itt, it1</code>, <code>it2</code></td>
<td>Objects of type <code>I</code></td>
</tr>
<tr>
<td><code>t</code></td>
<td>Object of type <code>T</code></td>
</tr>
<tr>
<td><code>n</code></td>
<td>Object of type <code>C::difference_type</code></td>
</tr>
</tbody>
</table>
<h4>Definitions</h4>
<p>An Indexed Random Access Iterator <code>it1</code> is
<i>reachable</i> from an Indexed Random Access Iterator
<code>it2</code> if, after applying <code>operator ++</code> to
<code>it2</code> a finite number of times, <code>it1 ==
it2</code>.</p>
<h4>Valid expressions</h4>
<p>In addition to the expressions defined for <a href=
"#indexed_bidirectional_iterator">Indexed Bidirectional
Iterator</a> , the following expressions must be valid.</p>
<table border="1" summary="expressions">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Type requirements</th>
<th>Return type</th>
</tr>
<tr>
<td>Forward motion</td>
<td><code>it += n</code></td>
<td>&nbsp;</td>
<td><code>I &amp;</code></td>
</tr>
<tr>
<td>Iterator addition</td>
<td><code>it + n</code></td>
<td>&nbsp;</td>
<td><code>I</code></td>
</tr>
<tr>
<td>Backward motion</td>
<td><code>i -= n</code></td>
<td>&nbsp;</td>
<td><code>I &amp;</code></td>
</tr>
<tr>
<td>Iterator subtraction</td>
<td><code>it - n</code></td>
<td>&nbsp;</td>
<td><code>I</code>&nbsp;</td>
</tr>
<tr>
<td>Difference</td>
<td><code>it1 - it2</code></td>
<td>&nbsp;</td>
<td><code>C::difference_type</code></td>
</tr>
<tr>
<td>Element operator</td>
<td><code>it [n]</code></td>
<td>&nbsp;</td>
<td>Convertible to <code>T</code>.</td>
</tr>
<tr>
<td>Element assignment</td>
<td><code>it [n] = t</code></td>
<td><code>I</code> is mutable</td>
<td>Convertible to <code>T</code>.</td>
</tr>
</tbody>
</table>
<h4>Expression Semantics</h4>
<p>Semantics of an expression is defined only where it differs
from, or is not defined in, <a href=
"#indexed_bidirectional_iterator">Indexed Bidirectional
Iterator</a> .</p>
<table border="1" summary="semantics">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Precondition</th>
<th>Semantics</th>
<th>Postcondition</th>
</tr>
<tr>
<td>Forward motion</td>
<td><code>it += n</code></td>
<td>Including <code>it</code> itself, there must be <code>n</code>
dereferenceable or past-the-end iterators following or preceding
<code>it</code>, depending on whether <code>n</code> is positive or
negative.</td>
<td>If <code>n &gt; 0</code>, equivalent to executing <code>++
it</code> <code>n</code> times. If <code>n &lt; 0</code>,
equivalent to executing <code>-- it</code> <code>n</code> times. If
<code>n == 0</code>, this is a null operation.</td>
<td><code>it</code> is dereferenceable or past-the-end.</td>
</tr>
<tr>
<td>Iterator addition</td>
<td><code>it + n</code></td>
<td>Same as for <code>i += n</code>.</td>
<td>Equivalent to<br />
<code>{<br />
&nbsp;I itt = it;<br />
&nbsp;return itt += n;<br />
}</code></td>
<td>Result is dereferenceable or past-the-end.</td>
</tr>
<tr>
<td>Backward motion</td>
<td><code>it -= n</code></td>
<td>Including <code>it</code> itself, there must be <code>n</code>
dereferenceable or past-the-end iterators preceding or following
<code>it</code>, depending on whether <code>n</code> is positive or
negative.</td>
<td>Equivalent to <code>it += (-n)</code>.</td>
<td><code>it</code> is dereferenceable or past-the-end.</td>
</tr>
<tr>
<td>Iterator subtraction</td>
<td><code>it - n</code></td>
<td>Same as for <code>i -= n</code>.</td>
<td>Equivalent to<br />
<code>{<br />
&nbsp;I itt = it;<br />
&nbsp;return itt -= n;<br />
}</code></td>
<td>Result is dereferenceable or past-the-end.</td>
</tr>
<tr>
<td>Difference</td>
<td><code>it1 - it2</code></td>
<td>Either <code>it1</code> is reachable from <code>it2</code> or
<code>it2</code> is reachable from <code>it1</code>, or both.</td>
<td>Returns a number <code>n</code> such that <code>it1 == it2 +
n</code></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Element operator</td>
<td><code>it [n]</code></td>
<td><code>it + n</code> exists and is dereferenceable.</td>
<td>Equivalent to <code>*(it + n)</code></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Element assignment</td>
<td><code>i[n] = t</code></td>
<td>Same as for <code>it [n]</code>.</td>
<td>Equivalent to <code>*(it + n) = t</code></td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<h4>Complexity guarantees</h4>
<p>The complexity of operations on indexed random access iterators
is guaranteed to be amortized constant time.</p>
<h4>Invariants</h4>
<table border="1" summary="invariants">
<tbody>
<tr>
<td>Symmetry of addition and subtraction</td>
<td>If <code>it + n</code> is well-defined, then <code>it += n; it
-= n;</code> and <code>(it + n) - n</code> are null operations.
Similarly, if <code>it - n</code> is well-defined, then <code>it -=
n; it += n;</code> and <code>(it - n) + n</code> are null
operations.</td>
</tr>
<tr>
<td>Relation between distance and addition</td>
<td>If <code>it1 - it2</code> is well-defined, then <code>it1 ==
it2 + (it1 - it2)</code>.</td>
</tr>
<tr>
<td>Reachability and distance</td>
<td>If <code>it1</code> is reachable from <code>it2</code>, then
<code>it1 - it2 &gt;= 0</code>.</td>
</tr>
</tbody>
</table>
<h4>Models</h4>
<ul>
<li><code>vector::iterator</code></li>
</ul>
<h2><a name="indexed_bidirectional_cr_iterator" id=
"indexed_bidirectional_cr_iterator"></a>Indexed Bidirectional Column/Row Iterator</h2>
<h4>Description</h4>
<p>An Indexed Bidirectional Column/Row Iterator is an iterator of a
container that can be dereferenced, incremented, decremented and
carries index information.</p>
<h4>Refinement of</h4>
<p>Assignable, Equality Comparable, Default Constructible.</p>
<h4>Associated types</h4>
<table border="1" summary="associated types">
<tbody>
<tr>
<td>Value type</td>
<td>The type of the value obtained by dereferencing a Indexed
Bidirectional Column/Row Iterator</td>
</tr>
<tr>
<td>Container type</td>
<td>The type of the container a Indexed Bidirectional Column/Row
Iterator points into.</td>
</tr>
</tbody>
</table>
<h4>Notation</h4>
<table border="0" summary="notation">
<tbody>
<tr>
<td><code>I1</code></td>
<td>A type that is a model of Indexed Bidirectional Column/Row
Iterator</td>
</tr>
<tr>
<td><code>I2</code></td>
<td>A type that is a model of Indexed Bidirectional Row/Column
Iterator</td>
</tr>
<tr>
<td><code>T</code></td>
<td>The value type of <code>I1</code> and <code>I2</code></td>
</tr>
<tr>
<td><code>C</code></td>
<td>The container type of <code>I1</code> and <code>I2</code></td>
</tr>
<tr>
<td><code>it1</code>, <code>it1t, it11</code>,
<code>it12</code></td>
<td>Objects of type <code>I1</code></td>
</tr>
<tr>
<td><code>it2</code>, <code>it2t</code></td>
<td>Objects of type <code>I2</code></td>
</tr>
<tr>
<td><code>t</code></td>
<td>Object of type <code>T</code></td>
</tr>
<tr>
<td><code>c</code></td>
<td>Object of type <code>C</code></td>
</tr>
</tbody>
</table>
<h4>Definitions</h4>
<h4>Valid expressions</h4>
<p>In addition to the expressions defined for Assignable, Equality
Comparable and Default Constructible, the following expressions
must be valid.</p>
<table border="1" summary="expressions">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Type requirements</th>
<th>Return type</th>
</tr>
<tr>
<td>Default constructor</td>
<td><code>I1 it</code></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Dereference</td>
<td><code>*it</code></td>
<td>&nbsp;</td>
<td>Convertible to <code>T</code>.</td>
</tr>
<tr>
<td>Dereference assignment</td>
<td><code>*it = t</code></td>
<td><code>I1</code> is mutable.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Member access</td>
<td><code>it-&gt;m</code></td>
<td><code>T</code> is a type for which <code>t.m</code> is
defined.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Preincrement</td>
<td><code>++ it</code></td>
<td>&nbsp;</td>
<td><code>I1 &amp;</code></td>
</tr>
<tr>
<td>Postincrement</td>
<td><code>it ++</code></td>
<td>&nbsp;</td>
<td><code>I1</code></td>
</tr>
<tr>
<td>Predecrement</td>
<td><code>-- it</code></td>
<td>&nbsp;</td>
<td><code>I1 &amp;</code></td>
</tr>
<tr>
<td>Postdecrement</td>
<td><code>it --</code></td>
<td>&nbsp;</td>
<td><code>I1</code></td>
</tr>
<tr>
<td>Row Index</td>
<td><code>it.index1 ()</code></td>
<td>&nbsp;</td>
<td><code>C::size_type</code></td>
</tr>
<tr>
<td>Column Index</td>
<td><code>it.index2 ()</code></td>
<td>&nbsp;</td>
<td><code>C::size_type</code></td>
</tr>
<tr>
<td>Row/Column Begin</td>
<td><code>it.begin ()</code></td>
<td>&nbsp;</td>
<td><code>I2</code></td>
</tr>
<tr>
<td>Row/Column End</td>
<td><code>it.end ()</code></td>
<td>&nbsp;</td>
<td><code>I2</code></td>
</tr>
<tr>
<td>Reverse Row/Column Begin</td>
<td><code>it.rbegin ()</code></td>
<td>&nbsp;</td>
<td><code>reverse_iterator&lt;I2&gt;</code></td>
</tr>
<tr>
<td>Reverse Row/Column End</td>
<td><code>it.rend ()</code></td>
<td>&nbsp;</td>
<td><code>reverse_iterator&lt;I2&gt;</code></td>
</tr>
</tbody>
</table>
<h4>Expression Semantics</h4>
<p>Semantics of an expression is defined only where it differs
from, or is not defined in, Assignable, Equality Comparable and
Default Constructible.</p>
<table border="1" summary="semantics">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Precondition</th>
<th>Semantics</th>
<th>Postcondition</th>
</tr>
<tr>
<td>Default constructor</td>
<td><code>I1 it</code></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><code>it</code> is singular.</td>
</tr>
<tr>
<td>Dereference</td>
<td><code>*it</code></td>
<td><code>it</code> is dereferenceable.</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Dereference assignment</td>
<td><code>*it = t</code></td>
<td>Same as for <code>*it</code>.</td>
<td>&nbsp;</td>
<td><code>*it</code> is a copy of t.</td>
</tr>
<tr>
<td>Member access</td>
<td><code>it-&gt;m</code></td>
<td><code>it</code> is dereferenceable.</td>
<td>Equivalent to <code>(*it).m</code></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Preincrement</td>
<td><code>++ it</code></td>
<td><code>it</code> is dereferenceable.</td>
<td><code>it</code> is modified to point to the next element of
the column/row, i.e. for column iterators holds<br />
<code>it.index1 () &lt; (++ it).index1 ()</code> and<br />
<code>it.index2 () == (++ it).index2 ()</code>,<br />
for row iterators holds<br />
<code>it.index1 () == (++ it).index1 ()</code> and<br />
<code>it.index2 () &lt; (++ it).index2 ()</code>.<br /></td>
<td><code>it</code> is dereferenceable or past-the-end.
<code><br />
&amp;it == &amp;++ it</code>.<br />
If <code>it1 == it2</code>,<br />
then <code>++ it1 == ++ it2</code>.</td>
</tr>
<tr>
<td>Postincrement</td>
<td><code>it ++</code></td>
<td>Same as for <code>++ it</code>.</td>
<td>Equivalent to<br />
<code>{<br />
&nbsp;I1 itt = it;<br />
&nbsp;++ it;<br />
&nbsp;return itt;<br />
}</code></td>
<td><code>it</code> is dereferenceable or past-the-end.</td>
</tr>
<tr>
<td>Predecrement</td>
<td><code>-- it</code></td>
<td><code>it</code> is dereferenceable or past-the-end.<br />
There exists a dereferenceable iterator <code>itt</code> such that
<code>it == ++ itt</code>.</td>
<td><code>it</code> is modified to point to the previous&nbsp;
element of the column/row, i.e. for column iterators holds<br />
<code>it.index1 () &gt; (-- it).index1 ()</code> and<br />
<code>it.index2 () == (-- it).index2 ()</code>,<br />
for row iterators holds<br />
<code>it.index1 () == (-- it).index1 ()</code> and<br />
<code>it.index2 () &gt; (-- it).index2 ()</code>.</td>
<td><code>it</code> is dereferenceable.<br />
<code>&amp;it = &amp;-- it</code>.<br />
If <code>it1 == it2</code>,<br />
then <code>-- it1 == -- it2</code>.</td>
</tr>
<tr>
<td>Postdecrement</td>
<td><code>it --</code></td>
<td>Same as for -- <code>it</code>.</td>
<td>Equivalent to<br />
<code>{<br />
&nbsp;I1 itt = it;<br />
&nbsp;-- it;<br />
&nbsp;return itt;<br />
}</code></td>
<td><code>it</code> is dereferenceable.&nbsp;</td>
</tr>
<tr>
<td>Row Index</td>
<td><code>it.index1 ()</code></td>
<td>If <code>it</code> is a Row iterator then <code>it</code> must be dereferenceable.</td>
<td><code>it.index1 () &gt;= 0</code> and<br />
<code>it.index1 () &lt; it () .size1 ()</code></td>
<td>If <code>it1 == it2</code>,<br />
then <code>it1.index1 () == 12.index1 ()</code>.<br />
If <code>it1</code>, <code>it2</code> are Row Iterators with <code>it1 == it2</code>,<br />
then <code>it1.index1 () &lt; (++ it2</code>).<code>index1 ()</code>.<br />
and <code>it1.index1 () &gt; (-- it2</code>).<code>index1 ()</code>.</td>
</tr>
<tr>
<td>Column Index</td>
<td><code>it.index2 ()</code></td>
<td>If <code>it</code> is a Column iterator then <code>it</code> must be dereferenceable.</td>
<td><code>it.index2 () &gt;= 0</code> and<br />
<code>it.index2 () &lt; it () .size2 ()</code></td>
<td>If <code>it1 == it2</code>,<br />
then <code>it1.index2 () == it2</code>.<code>index2 ()</code>
.<br />
If <code>it1</code>, <code>it2</code> are Column Iterators with <code>it1 == i12</code>,<br />
then <code>it1.index2 () &lt; (++ it2</code>).<code>index2 ()</code>.<br />
end <code>it1.index2 () &gt; (-- it2</code>).<code>index2 ()</code>.</td>
</tr>
<tr>
<td>Row/Column Begin</td>
<td><code>it.begin ()</code></td>
<td><code>it</code> is dereferenceable.</td>
<td>If <code>it</code> is a Column Iterator,<br />
then <code>it2 = it.begin ()</code> is a Row Iterator<br />
with <code>it2.index1 () == it.index1 ()</code>.
<p>If <code>it</code> is a Row Iterator,<br />
then <code>it2 = it.begin ()</code> is a Column Iterator<br />
with <code>it2.index2 () == it.index2 ()</code>.</p>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Row/Column End</td>
<td><code>it.end ()</code></td>
<td><code>it</code> is dereferenceable.</td>
<td>If <code>it</code> is a Column Iterator,<br />
then <code>it2 = it.end ()</code> is a Row Iterator<br />
with <code>it2.index1 () == it.index1 ()</code>.
<p>If <code>it</code> is a Row Iterator,<br />
then <code>it2 = it.end ()</code> is a Column Iterator<br />
with <code>it2.index2 () == it.index2 ()</code>.</p>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Reverse Row/Column Begin</td>
<td><code>it.rbegin ()</code></td>
<td><code>it</code> is dereferenceable.</td>
<td>Equivalent to <code>reverse_iterator&lt;I2&gt; (it.end
())</code>.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Reverse Row/Column End</td>
<td><code>it.rend ()</code></td>
<td><code>it</code> is dereferenceable.</td>
<td>Equivalent to <code>reverse_iterator&lt;I2&gt; (it.begin
())</code>.</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<h4>Complexity guarantees</h4>
<p>The complexity of operations on indexed bidirectional column/row
iterators is guaranteed to be logarithmic depending on the size of
the container. The complexity of one iterator (depending on the
storage layout) can be lifted to be amortized constant time. The
complexity of the other iterator (depending on the storage layout
and the container) can be lifted to be amortized constant time for
the first row/first column respectively.</p>
<h4>Invariants</h4>
<table border="1" summary="invariants">
<tbody>
<tr>
<td>Identity</td>
<td><code>it1 == it2</code> if and only if <code>&amp;*it1 ==
&amp;*it2</code>.</td>
</tr>
<tr>
<td>Symmetry of increment and decrement</td>
<td>If <code>it</code> is dereferenceable, then <code>++ it;
--it;</code> is a null operation. Similarly, <code>-- it; ++
it;</code> is a null operation.</td>
</tr>
<tr>
<td>Relation between iterator index and container element
operator</td>
<td>If <code>it</code> is dereferenceable, <code>*it == it ()
(it.index1 (), it.index2 ())</code></td>
</tr>
<tr>
<td>Relation between iterator column/row begin and iterator
index</td>
<td>If <code>it</code> is a Column Iterator
and <code>it2 = it.begin ()</code> then <code>it2.index2 () &lt;
it2t.index2 ()</code> for all <code>it2t</code> with <code>it2t ()
== it2 ()</code> and <code>it2t ().index1 () == it2 ().index1
()</code>.
<p>If <code>it</code> is a Row Iterator and
<code>it2 = it.begin ()</code> then <code>it2.index1 () &lt;
it2t.index1 ()</code> for all <code>it2t</code> with <code>it2t ()
== it2 ()</code> and <code>it2t ().index2 () == it2 ().index2
()</code>.</p>
</td>
</tr>
<tr>
<td>Relation between iterator column/row end and iterator
index</td>
<td>If <code>it</code> is a Column Iterator
and <code>it2 = it.end ()</code> then <code>it2.index2 () &gt;
it2t.index2 ()</code> for all <code>it2t</code> with <code>it2t ()
== it2 ()</code> and <code>it2t ().index1 () == it2 ().index1
()</code>.
<p>If <code>it</code> is a Row Iterator and
<code>it2 = it.end ()</code> then <code>it2.index1 () &gt;
it2t.index1 ()</code> for all <code>it2t</code> with <code>it2t ()
== it2 ()</code> and <code>it2t ().index2 () == it2 ().index2
()</code>.</p>
</td>
</tr>
</tbody>
</table>
<h4>Models</h4>
<ul>
<li><code>sparse_matrix::iterator1</code></li>
<li><code>sparse_matrix::iterator2</code></li>
</ul>
<h2><a name="indexed_random_access_cr_iterator" id=
"indexed_random_access_cr_iterator"></a>Indexed Random Access Column/Row Iterator</h2>
<h4>Description</h4>
<p>An Indexed Random Access Column/Row Iterator is an iterator of a
container that can be dereferenced, incremented, decremented and
carries index information.</p>
<h4>Refinement of</h4>
<p><a href="#indexed_bidirectional_cr_iterator">Indexed
Bidirectional Column/Row Iterator</a> .</p>
<h4>Associated types</h4>
<table border="1" summary="associated types">
<tbody>
<tr>
<td>Value type</td>
<td>The type of the value obtained by dereferencing a Indexed
Random Access Column/Row Iterator</td>
</tr>
<tr>
<td>Container type</td>
<td>The type of the container a Indexed Random Access Column/Row
Iterator points into.</td>
</tr>
</tbody>
</table>
<h4>Notation</h4>
<table border="0" summary="notation">
<tbody>
<tr>
<td><code>I</code></td>
<td>A type that is a model of Indexed Random Access Column/Row
Iterator</td>
</tr>
<tr>
<td><code>T</code></td>
<td>The value type of <code>I</code></td>
</tr>
<tr>
<td><code>C</code></td>
<td>The container type of <code>I</code></td>
</tr>
<tr>
<td><code>it</code>, <code>itt, it1</code>, <code>it2</code></td>
<td>Objects of type <code>I</code></td>
</tr>
<tr>
<td><code>t</code></td>
<td>Object of type <code>T</code></td>
</tr>
<tr>
<td><code>c</code></td>
<td>Object of type <code>C</code></td>
</tr>
</tbody>
</table>
<h4>Definitions</h4>
<h4>Valid expressions</h4>
<p>In addition to the expressions defined for <a href=
"#indexed_bidirectional_cr_iterator">Indexed Bidirectional
Column/Row Iterator</a> , the following expressions must be
valid.</p>
<table border="1" summary="expressions">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Type requirements</th>
<th>Return type</th>
</tr>
<tr>
<td>Forward motion</td>
<td><code>it += n</code></td>
<td>&nbsp;</td>
<td><code>I &amp;</code></td>
</tr>
<tr>
<td>Iterator addition</td>
<td><code>it + n</code></td>
<td>&nbsp;</td>
<td><code>I</code></td>
</tr>
<tr>
<td>Backward motion</td>
<td><code>i -= n</code></td>
<td>&nbsp;</td>
<td><code>I &amp;</code></td>
</tr>
<tr>
<td>Iterator subtraction</td>
<td><code>it - n</code></td>
<td>&nbsp;</td>
<td><code>I</code>&nbsp;</td>
</tr>
<tr>
<td>Difference</td>
<td><code>it1 - it2</code></td>
<td>&nbsp;</td>
<td><code>C::difference_type</code></td>
</tr>
<tr>
<td>Element operator</td>
<td><code>it [n]</code></td>
<td>&nbsp;</td>
<td>Convertible to <code>T</code>.</td>
</tr>
<tr>
<td>Element assignment</td>
<td><code>it [n] = t</code></td>
<td><code>I</code> is mutable</td>
<td>Convertible to <code>T</code>.</td>
</tr>
</tbody>
</table>
<h4>Expression Semantics</h4>
<p>Semantics of an expression is defined only where it differs
from, or is not defined in, <a href=
"#indexed_bidirectional_cr_iterator">Indexed Bidirectional
Column/Row Iterator</a> .</p>
<table border="1" summary="semantics">
<tbody>
<tr>
<th>Name</th>
<th>Expression</th>
<th>Precondition</th>
<th>Semantics</th>
<th>Postcondition</th>
</tr>
<tr>
<td>Forward motion</td>
<td><code>it += n</code></td>
<td>Including <code>it</code> itself, there must be <code>n</code>
dereferenceable or past-the-end iterators following or preceding
<code>it</code>, depending on whether <code>n</code> is positive or
negative.</td>
<td>If <code>n &gt; 0</code>, equivalent to executing <code>++
it</code> <code>n</code> times. If <code>n &lt; 0</code>,
equivalent to executing <code>-- it</code> <code>n</code> times. If
<code>n == 0</code>, this is a null operation.</td>
<td><code>it</code> is dereferenceable or past-the-end.</td>
</tr>
<tr>
<td>Iterator addition</td>
<td><code>it + n</code></td>
<td>Same as for <code>i += n</code>.</td>
<td>Equivalent to<br />
<code>{<br />
&nbsp;I itt = it;<br />
&nbsp;return itt += n;<br />
}</code></td>
<td>Result is dereferenceable or past-the-end.</td>
</tr>
<tr>
<td>Backward motion</td>
<td><code>it -= n</code></td>
<td>Including <code>it</code> itself, there must be <code>n</code>
dereferenceable or past-the-end iterators preceding or following
<code>it</code>, depending on whether <code>n</code> is positive or
negative.</td>
<td>Equivalent to <code>it += (-n)</code>.</td>
<td><code>it</code> is dereferenceable or past-the-end.</td>
</tr>
<tr>
<td>Iterator subtraction</td>
<td><code>it - n</code></td>
<td>Same as for <code>i -= n</code>.</td>
<td>Equivalent to<br />
<code>{<br />
&nbsp;I itt = it;<br />
&nbsp;return itt -= n;<br />
}</code></td>
<td>Result is dereferenceable or past-the-end.</td>
</tr>
<tr>
<td>Difference</td>
<td><code>it1 - it2</code></td>
<td>Either <code>it1</code> is reachable from <code>it2</code> or
<code>it2</code> is reachable from <code>it1</code>, or both.</td>
<td>Returns a number <code>n</code> such that <code>it1 == it2 +
n</code></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Element operator</td>
<td><code>it [n]</code></td>
<td><code>it + n</code> exists and is dereferenceable.</td>
<td>Equivalent to <code>*(it + n)</code></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Element assignment</td>
<td><code>i[n] = t</code></td>
<td>Same as for <code>it [n]</code>.</td>
<td>Equivalent to <code>*(it + n) = t</code></td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<h4>Complexity guarantees</h4>
<p>The complexity of operations on indexed random access Column/Row
iterators is guaranteed to be amortized constant time.</p>
<h4>Invariants</h4>
<table border="1" summary="invariants">
<tbody>
<tr>
<td>Symmetry of addition and subtraction</td>
<td>If <code>it + n</code> is well-defined, then <code>it += n; it
-= n;</code> and <code>(it + n) - n</code> are null operations.
Similarly, if <code>it - n</code> is well-defined, then <code>it -=
n; it += n;</code> and <code>(it - n) + n</code> are null
operations.</td>
</tr>
<tr>
<td>Relation between distance and addition</td>
<td>If <code>it1 - it2</code> is well-defined, then <code>it1 ==
it2 + (it1 - it2)</code>.</td>
</tr>
<tr>
<td>Reachability and distance</td>
<td>If <code>it1</code> is reachable from <code>it2</code>, then
<code>it1 - it2 &gt;= 0</code>.</td>
</tr>
</tbody>
</table>
<h4>Models</h4>
<ul>
<li><code>matrix::iterator1</code></li>
<li><code>matrix::iterator2</code></li>
</ul>
<hr />
<p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
Permission to copy, use, modify, sell and distribute this document
is granted provided this copyright notice appears in all copies.
This document is provided ``as is'' without express or implied
warranty, and with no claim as to its suitability for any
purpose.</p>
</body>
</html>