enumerator Questions
6
I have multithreads application and i get this error
************** Exception Text **************
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
...
Preside asked 29/3, 2012 at 12:14
3
Solved
Get the first item of an IEnumerable and return the rest as IEnumerable, iterating through only once
I've got an enumerable that contains responses from a service call that come in gradually.
I can't do ToList on the enumerable as that would block until all responses are received instead of lis...
Imbue asked 3/12, 2019 at 16:31
5
Solved
Does anyone know if there was a specific reason or design decision to not include a reverse enumerator in C#? It would be so nice if there was an equivalent to the C++ reverse_iterator just like En...
Pm asked 17/2, 2012 at 23:47
3
I have a tree that I'm trying to traverse. As I traverse it, I keep a stack of enumerators in which each enumerator is used to enumerate over a tree's children.
I'd like to be able to duplicate th...
Thao asked 19/11, 2012 at 14:11
2
Solved
Consider the following code:
[1,2,3].map.with_index { |x, i| x * i }
# => [0,2,6]
How does this work exactly?
My mental model of map is that it iterates and apply a function on each element. Is...
Reclinate asked 3/6, 2021 at 15:22
3
Solved
Let's say I have two enumerators, enum1 and enum2 that must be lazily iterated through (because they have side effects). How do I construct a third enumerator enum3 where enum3.each{|x| x} would la...
Lapotin asked 9/8, 2016 at 20:5
2
Solved
Is there real reason for this error in given code, or just It could go wrong in general usage where the reference would be needed across interator steps (which is not true in this case)?
IEnumerabl...
Regurgitate asked 3/9, 2020 at 17:33
4
Solved
I want to create an enumerator for external iteration via next that is clone-able, so that the clone retains the current enumeration state.
As an example, let's say I have a method that returns an ...
Sisterly asked 29/6, 2020 at 12:0
1
Solved
Consider the following benchmark:
[MemoryDiagnoser]
public class EnumerableBenchmark
{
private IEnumerable<string> _emptyArray = new string[0];
private IEnumerable<string> _notEmptyAr...
Noblesse asked 6/7, 2020 at 10:15
3
Solved
I have a method where I would like to decide what to return within a map function. I am aware that this can be done with assigning a variable, but this is how I though I could do it;
def some_meth...
Ales asked 6/9, 2016 at 13:18
1
Solved
If I have an EnumeratorT and a corresponding IterateeT I can run them together:
val en: EnumeratorT[String, Task] = EnumeratorT.enumList(List("a", "b", "c"))
val it: IterateeT[String, Task, Int] =...
Caulis asked 13/11, 2014 at 17:21
1
Solved
This is a spin-off question based on Eric Lippert's answer on this question.
I would like to know why the C# language is designed not being able to detect the correct interface member in the follo...
Sandalwood asked 3/7, 2019 at 18:5
5
If I create an Enumertor like so:
enum = [1,2,3].each => #<Enumerator: [1, 2, 3]:each>
enum is an Enumerator. What is the purpose of this object? I can't say this:
enum { |i| puts i }...
Warbeck asked 6/6, 2013 at 23:1
7
All string.Split methods seems to return an array of strings (string[]).
I'm wondering if there is a lazy variant that returns an IEnumerable<string> such that one for large strings (or an i...
Rigorous asked 27/1, 2015 at 19:33
2
Solved
I have an Enumerator in the middle of some sequence:
enum = (1..9).each
first = enum.next
second = enum.next
Now I want to cycle through the rest of the sequence (3..9 numbers). But seeming obvi...
Thornberry asked 28/4, 2018 at 9:46
1
Solved
In C++, specifically in C++14 n4296, there are two paragraps talking about type of an enumerator, which seem to be contradictory to me. See 7.2/5 (which is 10.2/5 in n4659):
Each enumeration def...
Adjunction asked 21/2, 2017 at 13:56
8
Solved
code:
c = 0
items.each { |i|
puts i.to_s
# if c > 9 escape the each iteration early - and do not repeat
c++
}
I want to grab the first 10 items then leave the "each" loop.
What...
Marsh asked 14/10, 2009 at 18:56
1
Solved
Ruby: undefined method `[]' for nil:NilClass when trying to get Enumerator on an Array of Hashes
I am trying to loop on an Array of Hashes. When I reach the point where I fetch the Enumerator to start looping, I get the following error:
undefined method `[]' for nil:NilClass
My code looks l...
Veterinary asked 6/1, 2017 at 20:44
2
Solved
When using
let directoryEnumerator = FileManager().enumerator(at: ...
in Swift 3, I get all files from the folder, e.g.
"file:///Volumes/MacOS/fasttemp/Fotos/"
The results are not including t...
Calvinna asked 3/11, 2016 at 8:48
2
Solved
Ruby
Ruby has each_cons that can be used like this
class Pair
def initialize(left, right)
@left = left
@right = right
end
end
votes = ["a", "b", "c", "d"]
pairs = votes.each_cons(2).map { |vo...
Teasel asked 28/9, 2016 at 19:41
3
Solved
I come from the world of Python and am trying to create a "generator" method in C#. I'm parsing a file in chunks of a specific buffer size, and only want to read and store the next chunk one at a t...
Rhythmics asked 8/7, 2016 at 20:14
3
Solved
I'm looking for a way to print the response body in Play framework, I have a code like this:
object AccessLoggingAction extends ActionBuilder[Request] {
def invokeBlock[A](request: Request[A], bl...
Ache asked 23/12, 2014 at 0:0
3
I am trying to implement a take_until method for Ruby 2's Enumerator::Lazy class. It should work similar to take_while but instead stop iteration when the yielded block returns true. The result sho...
Okhotsk asked 23/12, 2013 at 22:5
1
TLDR: Is there a thread-safe version of the Enumerator class in Ruby?
What I'm trying to do:
I have a method in a Ruby On Rails application that I wanted to run concurrently. The method is supp...
Velocipede asked 11/9, 2015 at 0:12
2
Solved
Could someone explain why this code is running in infinity loop? Why MoveNext() return true always?
var x = new { TempList = new List<int> { 1, 3, 6, 9 }.GetEnumerator() };
while (x.TempList...
Brigantine asked 23/7, 2015 at 15:5
1 Next >
© 2022 - 2024 — McMap. All rights reserved.