loops

C# Game loop help

Thanks alot for the help ...

When should I call SaveChanges() when creating 1000's of Entity Framework objects? (like during an import)

I am running an import that will have 1000's of records on each run. Just looking for some confirmation on my assumptions: Which of these makes the most sense: Run SaveChanges() every AddToClassName() call. Run SaveChanges() every n number of AddToClassName() calls. Run SaveChanges() after all of the AddToClassName() calls. The fir...

Python - assign lists within nest to variable

Hi folks, I am new to python and would appreciate a little help. How does one do the following: Having converted each line within a file to a nested list, e.g. [['line 1', 'a'], ['line 2','b']] how do I flatten the list so that each line is associated with a variable. Assume that the first member in each list, i.e. i[:][0], is known...

Python - ignore lines in a file

Hi folks, How does one ignore lines in a file? Example: If you know that the first lines in a file will begin with say, a or b and the remainder of lines end with c, how does one parse the file so that lines beginning a or b are ignored and lines ending c are converted to a nested list? What I have so far: fname = raw_input('Enter f...

iPhone AVAudioPlayer loop stuttering?

I have a sound that is about 2 seconds long which I have set it's it's numberOfLoops property to -1, but it has a .5 second lag between loops i want the sound to fade into itself when it is looping. Help please! ...

inline asm buffer loop

Ok here's my problem. I want to loop through a simple char buffer using inline asm and VC++; My agenda is to create a loop that reads information from memory as fast as physically possible heres my code char buffer[howmany]; memset(buffer,33,howmany); char arr = 0; __asm { MOV eax,seg buffer ;operand size conflict MOV eds,eax ...

PHP: how to iterate through an array, and resume where you left off?

Here's my array: $array = array(1,2,3,4,5,6,7,8,9,10); I want to iterate through the array 5 times, do something else, then resume iteration where I left off. foreach ($array as $value) { //do something until key 5 } //do something else now //resume... foreach ($array as $value) { //key should start at 6 } How can I do th...

Is there a quicker way to process a sequence of element than using a loop?

Here I am storing the elements of a datagrid in a string builder using a for loop, but it takes too much time when there is a large number of rows. Is there another way to copy the data in to a string builder in less time? for (int a = 0; a < grdMass.RowCount; a++) { if (a == 0) { _MSISDN.Appe...

instantiating a new class in a loop or not in a loop?

require_once('Class.php'); $myArray = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); // etc which is correct? foreach($myArray as $key => $val) { $class = new Class(); $result = $class->someMethod($val); } or $class = new Class(); foreach($myArray as $key => $val) { $result = $class->someMethod($val); } Edited to be more...

PHP-ILooping an arrays values through a larger array

I want to know if it is possible to take an array and insert the array's values into a bigger array, multiple times, so that the values of the smaller array fill up the bigger array. Say array1 has values ([0 => 'a'],[1 => 'b'],[2 => 'c']), and array2 can hold 8 values. So, how would I take the values of array1 and insert them into arr...

symfony inserting multiple records

i have problems inserting multiple records in symfony what happens is the 2nd up to the last records just updates the first record ex: $n = new Object(); // start loop until i = 5 $n->count = $i; $n->text = 'a'.$i; $n->save(); i++; //end loop after this loop theres only 1 record... count = 5, text= a5; is there a way to clear $n so...

delete array element with foreach loop?

i want to loop an array with foreach to check if a value exist. and if it does, i want to delete that element. i have following code: foreach($display_related_tags as $tag_name) { if($tag_name == $found_tag['name']); // DELETE CODE } but i dont know how to delete the element once the value is found. ho...

Order of items in objects in ActionScript

Try to compile: var object:Object = {}; object.one = "foo"; object.two = "foo"; object.three = "foo"; object.four = "foo"; for(var key:String in object) { trace(key); } ... you will get: one four two three Why the messed up order? ...

Does Python have any for loop equivalent (not foreach)

Python's iterators are great and all, but sometimes I really do want a C-style for loop - not a foreach loop. For example, I have a start date and an end date and I want to do something for every day in that range. I can do this with a while loop, of course: current = start while current <= finish: do_stuff(current) ...

ASP.NET adding controls inside a loop

Pardon me, this really is a noob question but please understand that I do not have much ASP.NET experience. All I need to do is: 1) Open up the following SQL query: SELECT myid FROM mytable 2) For each record, generate this fragment of HTML: <a href="#mynameanchor" onClick="myfunction( '__myid comes here__' );"><img src="http://some...

PHP - How to loop through a associative array and get the key name?

My associative array: $arr = array( 1 => "Value1" 2 => "Value2" 10 => "Value10" ); Using the following code, $v is filled with $arr's values foreach($arr as $v){ echo($v); // Value1, Value2, Value10 } How do I get $arr's keys instead? foreach(.....){ echo($k); // 1, 2, 10 } ...

How to rename files in a for loop in Perl

Hi, I am running a Perl script and try to accomplish renaming files as below.. I have a list of *.ru.jp files in a folder with other non related files. I would like to rename with a number which I have got as a counter variable. In Bash,I would do as ... for i in $(ls *.ru.jp); do x=${i%%.*}; mv $i "$x"t"$counter".ru.jp ;done E.g...

Best way for simple game-loop in Javascript?

Is there a simple way to make a game loop in JavaScript? something like... onTimerTick() { // update game state } ...

Jquery: mark links as visited without opening them?

I have no intention of just altering the link (I hear that's impossible, but if it's not I'd love to know how). I'm fine with adding it to the the browser history if that needs to be done. I'd like to loop through all <a>'s on a page and change their state to visited. For example: $("a").each(function(){ //mark as visited (somehow?)...

Does Java recognize infinite loops?

Given the following code sample: public class WeirdStuff { public static int doSomething() { while(true); } public static void main(String[] args) { doSomething(); } } This is a valid Java program, although the method doSomething() should return an int but never does. If you run it, it will end in an infinite loop. If you pu...