Replies: 4 comments
-
Hello, I understand this can be seen as a double operation but it is necessary as hasNext() method should not modify the state of the object. Calling it twice should lead to the same result. If saving an operation is that critical for your application, maybe you can do your own loop relying on nextInt() only and analysing if the value returned is >= offset or not, but I would not recommend it. |
Beta Was this translation helpful? Give feedback.
-
In the proposed code, calling |
Beta Was this translation helpful? Give feedback.
-
BUT, it seems that the |
Beta Was this translation helpful? Give feedback.
-
Perhaps I misunderstood, and now I am learning the design principle of the iterators in Choco. 😄😄😄 |
Beta Was this translation helpful? Give feedback.
-
Hi, i'm a leaner for constraint programming, and when i read the source code, i found a little problem.
for these two files in /choco/src/main/java/org/chocosolver/util/objects/setDataStructures/bitset:
your iterator for the bitset is here:
[
](https://github.com/chocoteam/choco-solver/tree/master/solver/src/main/java/org/chocosolver/util/objects/setDataStructures/bitset)
I think the method "values.nextSetBit(current+1)" is called twice when “hasNext()” and “nextInt()” are in a for loop at the same time.
Maybe we can avoid this situation:
I have tested the above code and there seems to be no errors and an improvement in efficiency.
I'm looking forward to the authors' replies. 😊😊😊😊
Beta Was this translation helpful? Give feedback.
All reactions