Re: [go-nuts] Re: Will deleting a key from a map in an iteration prevent some keys being iterated in the same iteration?

2017-05-03 Thread T L


On Tuesday, May 2, 2017 at 10:07:11 PM UTC+8, Keith Randall wrote:
>
> Yes, all keys present in the map at the start of iteration, that aren't 
> deleted during iteration, will be returned during iteration.
>

Thanks for the clarification.
 

>
> On Monday, May 1, 2017 at 4:51:56 AM UTC-4, T L wrote:
>>
>>
>>
>> On Monday, May 1, 2017 at 3:56:51 PM UTC+8, Paul Jolly wrote:
>>>
>>> I think the part of the spec you're after is under the heading: 
>>> https://golang.org/ref/spec#For_statements, specifically the 
>>> sub-heading of that link "For statements with range clause", specifically 
>>> point 3 in the enumerated list:
>>>
>>> *The iteration order over maps is not specified and is not guaranteed to 
 be the same from one iteration to the next. If map entries that have not 
 yet been reached are removed during iteration, the corresponding iteration 
 values will not be produced. If map entries are created during iteration, 
 that entry may be produced during the iteration or may be skipped. The 
 choice may vary for each entry created and from one iteration to the next. 
 If the map is nil, the number of iterations is 0.*
>>>
>>>
>>>
>>>
>>>
>> The guarantee I need is *every map entries created before the iteration 
>> will be reached if it is not removed even if some entries are removed in 
>> the iteration*.
>> Looks this is silly. :) The answer should be yes I think.
>>  
>>
>>>
>>> On 1 May 2017 at 08:51, T L  wrote:
>>>


 On Monday, May 1, 2017 at 3:50:11 PM UTC+8, T L wrote:
>
> for example
>
> for k, v := range m {
> if SatisfySomeCondition(k, v) {
> delete(m, k)
> }
> }
>
> will the above iteration guarantee to delete all k-v pairs from m?
>

  will the above iteration guarantee to delete all k-v pairs satisfying 
 a condition from m?

 -- 
 You received this message because you are subscribed to the Google 
 Groups "golang-nuts" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to golang-nuts...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Will deleting a key from a map in an iteration prevent some keys being iterated in the same iteration?

2017-05-02 Thread 'Keith Randall' via golang-nuts
Yes, all keys present in the map at the start of iteration, that aren't 
deleted during iteration, will be returned during iteration.

On Monday, May 1, 2017 at 4:51:56 AM UTC-4, T L wrote:
>
>
>
> On Monday, May 1, 2017 at 3:56:51 PM UTC+8, Paul Jolly wrote:
>>
>> I think the part of the spec you're after is under the heading: 
>> https://golang.org/ref/spec#For_statements, specifically the sub-heading 
>> of that link "For statements with range clause", specifically point 3 in 
>> the enumerated list:
>>
>> *The iteration order over maps is not specified and is not guaranteed to 
>>> be the same from one iteration to the next. If map entries that have not 
>>> yet been reached are removed during iteration, the corresponding iteration 
>>> values will not be produced. If map entries are created during iteration, 
>>> that entry may be produced during the iteration or may be skipped. The 
>>> choice may vary for each entry created and from one iteration to the next. 
>>> If the map is nil, the number of iterations is 0.*
>>
>>
>>
>>
>>
> The guarantee I need is *every map entries created before the iteration 
> will be reached if it is not removed even if some entries are removed in 
> the iteration*.
> Looks this is silly. :) The answer should be yes I think.
>  
>
>>
>> On 1 May 2017 at 08:51, T L  wrote:
>>
>>>
>>>
>>> On Monday, May 1, 2017 at 3:50:11 PM UTC+8, T L wrote:

 for example

 for k, v := range m {
 if SatisfySomeCondition(k, v) {
 delete(m, k)
 }
 }

 will the above iteration guarantee to delete all k-v pairs from m?

>>>
>>>  will the above iteration guarantee to delete all k-v pairs satisfying a 
>>> condition from m?
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to golang-nuts...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Will deleting a key from a map in an iteration prevent some keys being iterated in the same iteration?

2017-05-01 Thread T L


On Monday, May 1, 2017 at 3:56:51 PM UTC+8, Paul Jolly wrote:
>
> I think the part of the spec you're after is under the heading: 
> https://golang.org/ref/spec#For_statements, specifically the sub-heading 
> of that link "For statements with range clause", specifically point 3 in 
> the enumerated list:
>
> *The iteration order over maps is not specified and is not guaranteed to 
>> be the same from one iteration to the next. If map entries that have not 
>> yet been reached are removed during iteration, the corresponding iteration 
>> values will not be produced. If map entries are created during iteration, 
>> that entry may be produced during the iteration or may be skipped. The 
>> choice may vary for each entry created and from one iteration to the next. 
>> If the map is nil, the number of iterations is 0.*
>
>
>
>
>
The guarantee I need is *every map entries created before the iteration 
will be reached if it is not removed even if some entries are removed in 
the iteration*.
Looks this is silly. :) The answer should be yes I think.
 

>
> On 1 May 2017 at 08:51, T L  wrote:
>
>>
>>
>> On Monday, May 1, 2017 at 3:50:11 PM UTC+8, T L wrote:
>>>
>>> for example
>>>
>>> for k, v := range m {
>>> if SatisfySomeCondition(k, v) {
>>> delete(m, k)
>>> }
>>> }
>>>
>>> will the above iteration guarantee to delete all k-v pairs from m?
>>>
>>
>>  will the above iteration guarantee to delete all k-v pairs satisfying a 
>> condition from m?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Will deleting a key from a map in an iteration prevent some keys being iterated in the same iteration?

2017-05-01 Thread Paul Jolly
I think the part of the spec you're after is under the heading:
https://golang.org/ref/spec#For_statements, specifically the sub-heading of
that link "For statements with range clause", specifically point 3 in the
enumerated list:

*The iteration order over maps is not specified and is not guaranteed to be
> the same from one iteration to the next. If map entries that have not yet
> been reached are removed during iteration, the corresponding iteration
> values will not be produced. If map entries are created during iteration,
> that entry may be produced during the iteration or may be skipped. The
> choice may vary for each entry created and from one iteration to the next.
> If the map is nil, the number of iterations is 0.*





On 1 May 2017 at 08:51, T L  wrote:

>
>
> On Monday, May 1, 2017 at 3:50:11 PM UTC+8, T L wrote:
>>
>> for example
>>
>> for k, v := range m {
>> if SatisfySomeCondition(k, v) {
>> delete(m, k)
>> }
>> }
>>
>> will the above iteration guarantee to delete all k-v pairs from m?
>>
>
>  will the above iteration guarantee to delete all k-v pairs satisfying a
> condition from m?
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Will deleting a key from a map in an iteration prevent some keys being iterated in the same iteration?

2017-05-01 Thread T L


On Monday, May 1, 2017 at 3:50:11 PM UTC+8, T L wrote:
>
> for example
>
> for k, v := range m {
> if SatisfySomeCondition(k, v) {
> delete(m, k)
> }
> }
>
> will the above iteration guarantee to delete all k-v pairs from m?
>

 will the above iteration guarantee to delete all k-v pairs satisfying a 
condition from m?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.