for-loop

what is the difference between for (or) foreach loop and linq query in case of speed

i like to know difference retrieval from list using for (or) foreach loop and retrieval from list using linq query. specially in case of speed and other difference EXample: List A=new List() contains 10000 rows i need to copy filter some rows from list A which one better in case of speed am i go with for loop or linq query ...

Looping stuff and getting the stuff into a table

I am new to javascript/jquery so this is a noob question :) I am trying to get stuff into table with jquery. The stuff/data is in attributes and array and I would need to go trough that array to get that stuff. In this I put some content into a array: $(Stuff).find("desc").each(function(index) { stuffArray[index]=$(this).text(); }); ...

Print a table in cmd in java

I have the following matrix 1 2 3 4 5 6 2 3 4 5 6 1 3 4 5 6 1 2 4 5 6 1 2 3 5 6 1 2 3 4 6 1 2 3 4 5 ...and I want to have it in a table | 1 2 3 4 5 6 --------------- 1| 1 2 3 4 5 6 2| 2 3 4 5 6 1 3| 3 4 5 6 1 2 4| 4 5 6 1 2 3 5| 5 6 1 2 3 4 6| 6 1 2 3 4 5 Having n elements is it possible to print such a table dynamically? ...

Javascript String Match Vs for loop

Hi All, I have an extjs grid and one of the column renderer function has a for loop which goes through an array of numbers and compares them with the value for every cell for the column in consideration. so I was thinking since the renderer already loops for each row, and now i have for loop runner for each row. The question is should...

What does ":" mean in this Java statement?

for (Season time : Season.values() ) system.out.println (time+ "\t" + time.getSpan()); I see an example for enumeration using :. What does this mean? ...

looping through a multi-dimensional array in Smarty

I have a multi-dimensional array generated in PHP: array( 'Requirements' => array( 'export_requirements' => array('value'=> 1, 'label'=> 'Export'), 'add_requirements' => array('value'=> 2, 'label'=> 'Add'), 'add_private_requirements' => array('value'=> 4, 'label'=> 'Add Private...

Python: Optimize this loop~~~~~~~~~~~

a = [(1,2),(3,1),(4,4),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5)] # Quite a lot tuples in the list, 6 digits~ # I want to split it into rows and columns. rows = 5 cols = 5 Data structure is rows and cols are the index for the bit list [rows, cols, (data)] I use loop to do this, but it ta...

Python list: How to read the previous element when using for loop?

Possible Duplicates: Python - Previous and next values inside a loop python for loop, how to find next value(object)? Hi, everyone. I've got a list contains a lot of elements, I iterate the list using a for loop. For example li = [2,31,321,41,3423,4,234,24,32,42,3,24,,31,123] for (i in li): print i But I want to get...

How to output a the contents of an array selectively with a IF statement

I have having some trouble printing a "char" from an ASCII value stored in an array. The goal overall is to read a string of input from the user, store that in an array. Then use another array to count the number of times each character appears in the string, storing the number of occurances in the array address that matches the ASCII c...

comparing two lists, python

I should define a function overlapping() that takes two lists and returns True if they have at least one member in common, False otherwise. For the sake of the exercise, I should write it using two nested for-loops. What am I doing wrong? def overlapping(a,b): for char in a: for char2 in b: return char in char2 ...

Incrementing [i] in the for-loop does not work

Hello everybody, this seems to be a simple question and I hope you can help me. I'd like to add that my code works the way I'm describing it. I'm not content with the way I solved my problem concerning my problem in incrementing [i] outside the for-loop. What I want is to get a sidebar menu shown when one hovers over an image. My CSS...

Is there a way of using orderby in a forloop C#?

Hi I have a for loop where i want to orderby the name alphabetically a b c d looking how to do this, wondered even if i could use linq orderby inside the forloop? ...

Pausing/resuming jobs based on job's datamap (Quartz.NET)

How easy would it be to be able to pause and resume jobs, based on whether they have a specific entry in their datamap? Would something like this work) foreach jobdetail if (dataMap.GetBoolean("config1") == true) pause job end if end for Can anyone give me ideas on how to construct the foreach look to loop for ev...

a simple problem with ForLoop in C#

I want it to run three times but it actually never runs the loop and gets out. In VB 6.0 I could do that with a similar structure but how can I achieve the same thing with C# for loop? I want to to count down but it is not ALWAYS the case, sometimes I am passing "1" and sometimes "-1" for the step , when passed with "-1" it does not work...

Flash AS2 show text one by one from array

Hi, I want to dynamically display some text from an array one after another in a dynamic textfield. var wordList:Array = new Array('one','two','three'); for (var i = 0; i < wordList.length; i++) { this.text_mc.txt.text = wordlist[i]; // Pause for 3 seconds and then move next } its the "Pause for 3 seconds and then move next"...

At least two errors: (syntax) CS0103 and (crashing program) for Loop

I am having two major problems with the source code below (and probably other problems I haven't yet discovered...). Problem Number 1: I have to apply the declared integer fields (day, month, year) under the class Friend to a string array in my Main() method. The way that I wrote the source code below doesn't allow for a definition for...

Java HashMap put in a for loop in

I have a for loop, where i check if there is a certain key in a HashMap, if the key is not there, it should put a new association in the HashMap. The problem is that that it puts the association, but by the next iteration of the loop the association is gone! I don't get it! public void DrawBoard(ArrayList<Integer[]> BoardList, int Frame...

How do I run through an array where the first array member is a string that needs to be split.

I have an array {{".txt|.doc|.docx", "100000"}, {".xls|.xlsx|.xxx" , "10000"}, ".npp", "100000"} I am trying to find a way to run a foreach loop on each member of the array in a loop while also checking the first member as a string not an array. The code will search for all docs greater than 10000 bytes, as long as the docs are txt, do...