public bool MoveNext() { currentEntry = default(DictionaryEntry); // if index points to pre-1st element... if (_keyIndex < 0) { _keyIndex++; _store.Locker.Lock(OperationType.Read); try { if (_store.Search(_keys[_keyIndex], true)) { currentEntry = _store.CurrentEntry; return(true); } } finally { _store.Locker.Unlock(OperationType.Read); } while (++_keyIndex <= _keys.Length - 1) { _store.Locker.Lock(OperationType.Read); try { if (_store.Search(_keys[_keyIndex], true)) { currentEntry = _store.CurrentEntry; return(true); } } finally { _store.Locker.Unlock(OperationType.Read); } } return(false); } // move store pointer to next element and if it has same key as current one in keys array, // just return true so Store can return this element. _store.Locker.Lock(OperationType.Read); try { if (_store.MoveNext() && _store.Comparer.Compare(_store.CurrentKey, _keys[_keyIndex]) == 0) { currentEntry = _store.CurrentEntry; return(true); } } finally { _store.Locker.Unlock(OperationType.Read); } while (++_keyIndex <= _keys.Length - 1) { _store.Locker.Lock(OperationType.Read); try { if (_store.Search(_keys[_keyIndex], true)) { currentEntry = _store.CurrentEntry; return(true); } } finally { _store.Locker.Unlock(OperationType.Read); } } return(false); }
public bool MoveNext() { currentEntry = default(DictionaryEntry); // if index points to pre-1st element... if (_wasReset) { _wasReset = false; if (!_source.MoveNext()) { return(false); } _target.Locker.Lock(OperationType.Read); try { if (_target.Search(_sourceKeyExtractor(_source.Current), true)) { currentEntry = _target.CurrentEntry; return(true); } } finally { _target.Locker.Unlock(OperationType.Read); } while (_source.MoveNext()) { _target.Locker.Lock(OperationType.Read); try { if (_target.Search(_sourceKeyExtractor(_source.Current), true)) { currentEntry = _target.CurrentEntry; return(true); } } finally { _target.Locker.Unlock(OperationType.Read); } } return(false); } // move store pointer to next element and if it has same key as current one in keys array, // just return true so Store can return this element. _target.Locker.Lock(OperationType.Read); try { if (_target.MoveNext() && _target.Comparer.Compare(_target.CurrentKey, _sourceKeyExtractor(_source.Current)) == 0) { currentEntry = _target.CurrentEntry; return(true); } } finally { _target.Locker.Unlock(OperationType.Read); } while (SourceMoveNextUniqueKey()) { _target.Locker.Lock(OperationType.Read); try { if (_target.Search(_sourceKeyExtractor(_source.Current), true)) { currentEntry = _target.CurrentEntry; return(true); } } finally { _target.Locker.Unlock(OperationType.Read); } } return(false); }