iteration

How to synchronize asynchronous methods?

var arguments = new double[] { 1d, 2d, 3d }; var result = arguments.Select(arg => Math.Sqrt(arg)); Now imagine a asynchronous method instead of Math.Sqrt (i'm not sure the method below is a true async method, but it behaves approximately like one) public void BeginSqrt(Action<double> callback, double argument) { Thread.Sleep(100);...

Efficient way of calling set of functions in Python

I have a set of functions: functions=set(...) All the functions need one parameter x. What is the most efficient way in python of doing something similar to: for function in functions: function(x) ...

How do I iterate through instances of a class in C#?

Is there a way to iterate over instances of a class in C#? These instances are not tracked or managed in a collection. ...

What is the difference between release and iteration?

The title says What is the difference between release and iteration? Can you explain what the difference is? ...

C++: Iterating through a vector of vectors

Hey there! I'm doing this project and right now I'm trying to: create some of objects and store them in vectors, which get stored in another vector V iterate through the vectors inside V iterate through the objects inside the individual vectors Anyway, I was just searching the web and I came accross the stl for_each function. It seem...

Is it possible to get the value for a key in a Hashtable without iteration?

Using .NET 3.5, is there a way to retrieve a value from Hashtable corresponding to the key without iteration? ...

Iterating over same type struct members in C

Is it possible to iterate of a C struct, where all members are of same type, using a pointer. Here's some sample code that does not compile: #include <stdio.h> #include <stdlib.h> typedef struct { int mem1 ; int mem2 ; int mem3 ; int mem4 ; } foo ; void my_func( foo* data ) { int i ; int* tmp = data ; // This ...

is the Java HashMap keySet() iteration order consistent?

I understand that the Set returned from a Map's keySet() method does not guarantee any particular order. My question is, does it guarantee the same order over multiple iterations. For example Map<K,V> map = getMap(); for( K k : map.keySet() ) { } ... for( K k : map.keySet() ) { } In the above code, assuming that the map is not mo...

Should I use jQuery.each()?

I'm doing very frequent iterations over arrays of objects and have been using jQuery.each(). However, I'm having speed and memory issues and one of the most called methods according to my profiler is jQuery.each(). What's the word on the street about its performance? Should I switch to a simple for loop? Of course I'm fixing the many iss...

Matlab loops for a function

Hi, I am trying to make a loop to redo a Matlab function 1000 times. Here's the program d = unifrnd (0,10,[10,1]); c = d.^(-2); a = round(unifrnd(0,1,[1,10]); e = a*c btotal = e+1 SIR = 1/btotal What I want is to iterate this function 1000 times, each time the value of SIR will vary due to the random number generated. For every iterat...

jQuery iterate over object with $.each

I have an object options: options = {title : 'title1', name : 'name1', url : 'url1', etc.} which is passed in as a parameter to a function. I'm trying to iterate over that object, pass it through another function evaluate, and store the result in another object opts, like so: var opts = new Object(); $.each(options, function(key,valu...

Query on iteration

Hi All, I want to written a object holding data read from xml String data = null; while ((data = stdInput.readLine()) != null) { logger.info("Data:"+data); } i want to return a obj holding the complete data read in while loop,how would i do that? its java ...

Is there a better way to iterate over two lists, getting one element from each list for each iteration?

I have a list of Latitudes and one of Longitudes and need to iterate over the latitude and longitude pairs. Do you think it's be better to: A) (assume that equal lengths is already checked) for i in range(len(Latitudes): Lat,Long=(Latitudes[i],Longitudes[i]) *** EDIT .... or, B) for Lat,Long in [(x,y) for x in Latitudes for...

"For" loop first iteration

Greetings pyc-sires and py-ladies, I would like to inquire if there is an elegant pythonic way of executing some function on the first loop iteration. The only possibility I can think of is: first = True for member in something.get(): if first: root.copy(member) first = False else: somewhereElse.copy(memb...

Iterating quickly through Outlook appointment items

I've written a macro which iterates through a users calendar and makes modifications to entries that fufil a certain critera. The problem is that when the calendar is very big, this takes a long time to do. I don't seem to be able to filter the appointments because oAppointmentItems seems to store entries as they were created - which is...

How to iterate over a string using a buffer (python)

Hi all, I'm trying to find some code that, given a string, will allow me to iterate over each line using the for loop construct, but with the added requirement that separate for loop constructs will not reset the iteration back to the beginning. At the moment I have sList = [line for line in theString.split(os.linesep)] for line in SL...

Python, Huge Iteration Performance Problem

Hi I'm doing an iteration through 3 words, each about 5 million characters long, and I want to find sequences of 20 characters that identifies each word. That is, I want to find all sequences of length 20 in one word that is unique for that word. My problem is that the code I've written takes an extremely long time to run. I've never ev...

In an ANT build.xml file, how can I iterate over the items in the ${env} variable?

This is in a Windows XP environment. I'm trying to install and edit some files that have default settings. I want to update these settings use items from ${env} ...

Convert function from recursion to iteration

Hello, I have this function that I wrote that is abysmally slow since php does not handle recursion well. I am trying to convert it to a while loop, but am having trouble wrapping my head around how to do it. Can anyone give me some tips? public function findRoute($curLoc, $distanceSoFar, $expectedValue) { $this->locationsVis...

Codeigniter: Make field increase by 1 up to a number?

In my validation class I have this: $fields['a_1'] = 'First Question'; $fields['a_2'] = 'Second Question'; $fields['a_3'] = 'Third Question'; $fields['a_4'] = 'Fourth Question'; This is getting old--I have about 40 of these to write, and each set has matching validation rules: $rules['a_1'] = 'hour'; $rules['a...