IEnumerable<NeuralVectors> DoGetNextVectors(IndexSet indexes) { var privIndexes = new IndexSet(indexes); foreach (int index in privIndexes.ToList()) { string key = CacheKeyPrefix + index; var foundVector = cache[key] as NeuralVectors; if (foundVector != null) { yield return foundVector; privIndexes.Remove(index); } } if (privIndexes.Count > 0) { var indexList = privIndexes.ToList(); int listIndex = 0; foreach (var vector in BaseProvider.GetNextVectors(privIndexes)) { int vectorIndex = indexList[listIndex++]; string key = CacheKeyPrefix + vectorIndex; cache[key] = vector; keys.Add(key); yield return vector; } } }