rfc:arrayiterator-improvements

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
rfc:arrayiterator-improvements [2016/11/24 21:10] wesnetmorfc:arrayiterator-improvements [2016/11/25 19:09] wesnetmo
Line 17: Line 17:
 The existing method ''ArrayIterator::seek($position)'' searches for the Entry in a linear manner, and this is not ideal for many uses, as what it does is simply iterating over the array (or part of it) to reach the specified position (or key, assuming the array is a list). Instead, the proposed method ''ArrayIterator::seekKey($key)'' would be a ''O(1)'' operation as the cursor can immediately jump to the Entry identified by the given ''$key''. The existing method ''ArrayIterator::seek($position)'' searches for the Entry in a linear manner, and this is not ideal for many uses, as what it does is simply iterating over the array (or part of it) to reach the specified position (or key, assuming the array is a list). Instead, the proposed method ''ArrayIterator::seekKey($key)'' would be a ''O(1)'' operation as the cursor can immediately jump to the Entry identified by the given ''$key''.
  
-Specifically, if the given key is present in the array the method would successfully return ''null''; subsequent calls to ''ArrayIterator::current()'' would get the value associated with the specified ''$key'', ''ArrayIterator::key()'' would get ''$key'' and so on, like it would normally behave when iterating over the Entry. Instead, if the provided key is not present in the array, and exactly like ''ArrayIterator::seek($position)'', the method would throw a ''OutOfBoundsException'' and keep the current ''ArrayIterator'''s cursor state.+Specifically, if the given key is present in the array the method would successfully execute such that subsequent calls to ''ArrayIterator::current()'' would get the value associated with the specified ''$key'', ''ArrayIterator::key()'' would get ''$key'' and so on, like it would normally behave when iterating over the Entry. Instead, if the provided key is not present in the array, and exactly like ''ArrayIterator::seek($position)'', the method would throw a ''OutOfBoundsException'' and keep the current ''ArrayIterator'''s cursor state.
  
 ===== ArrayIterator::prev():void ===== ===== ArrayIterator::prev():void =====
rfc/arrayiterator-improvements.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1