Click here to Skip to main content
15,891,248 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 10:34
professionalSander Rossel17-Aug-19 10:34 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 10:30
mvahoney the codewitch16-Aug-19 10:30 
GeneralRe: when algorithms attack Pin
Sander Rossel16-Aug-19 10:59
professionalSander Rossel16-Aug-19 10:59 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 11:02
mvahoney the codewitch16-Aug-19 11:02 
GeneralRe: when algorithms attack Pin
Sander Rossel16-Aug-19 11:09
professionalSander Rossel16-Aug-19 11:09 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 11:16
mvahoney the codewitch16-Aug-19 11:16 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 1:35
professionalSander Rossel17-Aug-19 1:35 
GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 3:16
mvahoney the codewitch17-Aug-19 3:16 
1. They are not the same. One is prefix and the other is postfix for a couple of reasons. But it *would* be the same here, sort of. Except in C++, i++ creates a copy of I, whereas ++i is just the simple asm "inc ax" basically. i++ isn't quite as efficient.

I code in C++, so this is habit. In fact I want to call this ++C Big Grin | :-D You'll find others with C++ backgrounds sometimes use ++i too.


2. Yes I really like foreach, and I use it a lot. But not if I don't have to. Frankly, if it didn't create an object on the heap every foreach, I'd probably use it almost everywhere.

3. Because look carefully. In that loop I'm modifying the passed in collection. I work only on a copy. You cannot modify a collection you are currently enumerating. Hence I must make a copy, enumerate that and work on result. Also note that's in a loop. I create this copy each time around, because I must.

And a note on your code.

C#
for(var i = 0;i<list.Count;++i);
is somewhat less efficient than

C#
for(int ic=list.Count,i=0;i<ic;++i);
because you're calling Count on every iteration when you don't have to.

alse HandleRules is unnecessary. Literally all you factored was the loop itself.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.


modified 17-Aug-19 9:26am.

GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 4:08
professionalSander Rossel17-Aug-19 4:08 
GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 4:14
mvahoney the codewitch17-Aug-19 4:14 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 4:27
professionalSander Rossel17-Aug-19 4:27 
GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 4:30
mvahoney the codewitch17-Aug-19 4:30 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 4:32
professionalSander Rossel17-Aug-19 4:32 
GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 4:41
mvahoney the codewitch17-Aug-19 4:41 
GeneralRe: when algorithms attack Pin
dandy7216-Aug-19 5:06
dandy7216-Aug-19 5:06 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 5:08
mvahoney the codewitch16-Aug-19 5:08 
GeneralRe: when algorithms attack Pin
dandy7216-Aug-19 5:11
dandy7216-Aug-19 5:11 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 5:12
mvahoney the codewitch16-Aug-19 5:12 
GeneralRe: when algorithms attack Pin
dandy7216-Aug-19 5:16
dandy7216-Aug-19 5:16 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 5:20
mvahoney the codewitch16-Aug-19 5:20 
GeneralRe: when algorithms attack Pin
Jon McKee16-Aug-19 9:31
professionalJon McKee16-Aug-19 9:31 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 9:35
mvahoney the codewitch16-Aug-19 9:35 
GeneralRe: when algorithms attack Pin
Jon McKee16-Aug-19 10:33
professionalJon McKee16-Aug-19 10:33 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 10:35
mvahoney the codewitch16-Aug-19 10:35 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 9:39
mvahoney the codewitch16-Aug-19 9:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.