@@ -39,41 +39,33 @@ printf("Inserted: %d\n", $writeResult->getInsertedCount());
3939
4040$ cursor = $ manager ->executeQuery (NS , new MongoDB \Driver \Query (array ()));
4141$ a = new MyIteratorIterator ($ cursor , 'A ' );
42- $ b = new MyIteratorIterator ($ cursor , 'B ' );
4342
4443echo "\nBefore rewinding, position and current element are not populated: \n" ;
4544$ a ->dump ();
46- $ b ->dump ();
4745
4846echo "\nAfter rewinding, current element is populated: \n" ;
4947$ a ->rewind ();
50- $ b ->rewind ();
5148$ a ->dump ();
52- $ b ->dump ();
5349
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" ;
5951$ a ->next ();
6052$ a ->dump ();
6153
6254echo "\nRewinding only populates current element and does not alter position: \n" ;
6355$ a ->rewind ();
6456$ a ->dump ();
65- $ b ->rewind ();
66- $ b ->dump ();
6757
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 ();
6961$ a ->next ();
7062$ a ->dump ();
7163$ a ->next ();
7264$ a ->dump ();
7365
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 ();
7769
7870?>
7971===DONE===
@@ -83,25 +75,21 @@ Inserted: 5
8375
8476Before rewinding, position and current element are not populated:
8577A: null => null
86- B: null => null
8778
8879After rewinding, current element is populated:
8980A: 0 => {_id: 0}
90- B: 0 => {_id: 0}
9181
92- Multiple iterators have their own position, but share the same Cursor buffer :
82+ After advancing, next element is populated :
9383A: 1 => {_id: 1}
94- B: 1 => {_id: 2}
95- A: 2 => {_id: 3}
9684
9785Rewinding only populates current element and does not alter position:
98- A: 2 => {_id: 3}
99- B: 1 => {_id: 3}
86+ A: 1 => {_id: 1}
10087
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}
10492
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
10795===DONE===
0 commit comments