@@ -39,41 +39,33 @@ printf("Inserted: %d\n", $writeResult->getInsertedCount());
39
39
40
40
$ cursor = $ manager ->executeQuery (NS , new MongoDB \Driver \Query (array ()));
41
41
$ a = new MyIteratorIterator ($ cursor , 'A ' );
42
- $ b = new MyIteratorIterator ($ cursor , 'B ' );
43
42
44
43
echo "\nBefore rewinding, position and current element are not populated: \n" ;
45
44
$ a ->dump ();
46
- $ b ->dump ();
47
45
48
46
echo "\nAfter rewinding, current element is populated: \n" ;
49
47
$ a ->rewind ();
50
- $ b ->rewind ();
51
48
$ a ->dump ();
52
- $ b ->dump ();
53
49
54
- echo "\nMultiple iterators have their own position, but share the same Cursor buffer: \n" ;
55
- $ a ->next ();
56
- $ a ->dump ();
57
- $ b ->next ();
58
- $ b ->dump ();
50
+ echo "\nAfter advancing, next element is populated: \n" ;
59
51
$ a ->next ();
60
52
$ a ->dump ();
61
53
62
54
echo "\nRewinding only populates current element and does not alter position: \n" ;
63
55
$ a ->rewind ();
64
56
$ a ->dump ();
65
- $ b ->rewind ();
66
- $ b ->dump ();
67
57
68
- echo "\nAdvancing first iterator until end of shared Cursor buffer is reached: \n" ;
58
+ echo "\nAdvancing through remaining elements: \n" ;
59
+ $ a ->next ();
60
+ $ a ->dump ();
69
61
$ a ->next ();
70
62
$ a ->dump ();
71
63
$ a ->next ();
72
64
$ a ->dump ();
73
65
74
- echo "\n Rewinding second iterator to position it at end of shared Cursor buffer : \n" ;
75
- $ b -> rewind ();
76
- $ b ->dump ();
66
+ echo "\n Advancing beyond the last element : \n" ;
67
+ $ a -> next ();
68
+ $ a ->dump ();
77
69
78
70
?>
79
71
===DONE===
@@ -83,25 +75,21 @@ Inserted: 5
83
75
84
76
Before rewinding, position and current element are not populated:
85
77
A: null => null
86
- B: null => null
87
78
88
79
After rewinding, current element is populated:
89
80
A: 0 => {_id: 0}
90
- B: 0 => {_id: 0}
91
81
92
- Multiple iterators have their own position, but share the same Cursor buffer :
82
+ After advancing, next element is populated :
93
83
A: 1 => {_id: 1}
94
- B: 1 => {_id: 2}
95
- A: 2 => {_id: 3}
96
84
97
85
Rewinding only populates current element and does not alter position:
98
- A: 2 => {_id: 3}
99
- B: 1 => {_id: 3}
86
+ A: 1 => {_id: 1}
100
87
101
- Advancing first iterator until end of shared Cursor buffer is reached:
102
- A: 3 => {_id: 4}
103
- A: null => null
88
+ Advancing through remaining elements:
89
+ A: 2 => {_id: 2}
90
+ A: 3 => {_id: 3}
91
+ A: 4 => {_id: 4}
104
92
105
- Rewinding second iterator to position it at end of shared Cursor buffer :
106
- B : null => null
93
+ Advancing beyond the last element :
94
+ A : null => null
107
95
===DONE===
0 commit comments