iterate

haXe and arrays Dynamic type

Hi, I know it's unlikely but maybe there is someone who knows haXe language. I have a variable of Dynamic type and I know for sure one of it's fields, lets call it an 'a' actually is an array. But when I'm writing var d : Dynamic = getDynamic(); for (t in d.a) { } I get a compilation error on line two, saying 'You can't iterate on a ...

What is the best way to iterate over a Dictionary in C#?

I've seen a few different ways to iterate over a Dictionary in C#. Is there a standard way? ...

C#, For Loops, and speed test... Exact same loop faster second time around?

public Int64 ReturnDifferenceA() { User[] arrayList; Int64 firstTicks; IList<User> userList; Int64 secondTicks; System.Diagnostics.Stopwatch watch; userList = Enumerable .Range(0, 1000) .Select(currentItem => new User()).ToList(); arrayList = userList.ToArray(); watch = new Stopwatch(); wa...

What is the "right" way to iterate through an array in Ruby?

PHP, for all its warts, is pretty good on this count. There's no difference between an array and a hash (maybe I'm naive, but this seems obviously right to me), and to iterate through either you just do foreach (array/hash as $key => $value) In Ruby there are a bunch of ways to do this sort of thing: array.length.times do |i| end ar...

How do you iterate through custom keys in web.config?

Hi, is it possible to create my own custom keys in the asp.net web.config file and iterate through them with C#? How do you do both (where do I put the key? what format?)? I have an application for an intranet that does certain things based upon the IP address of the client. Instead of hard coding those in the codebehind file, I thou...

C# enums as function parameters?

Can you pass a standard c# enum as a parameter? For example: enum e1 { //... } enum e2 { //... } public void test() { myFunc( e1 ); myFunc( e2 ); } public void myFunc( Enum e ) { // Iterate through all the values in e } By doing this I hope to retrieve all the names within any given enum. What would the Iterat...

Why can't I push this object onto my std::list?

Just started programming in C++. I've created a Point class, a std::list and an iterator like so: class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; std::list <Point> pointList; std::list <Point>::iterator iter; I then push new points onto pointList. Now, I'm needing to ite...

How to do a multiple keyword search?

I have 2 tables to search. Searching photos for keywords, title and description. The keywords have been split off into a separate table. My advanced search will allow searching on all 3 but the basic will just be the keyword table. Basic table setup: PHOTO Table PhotoID Name Title Description WORD2PHOTO Table WordID PhotoID Word ...

Method to find Key in HashTable

I'm trying to create a method which iterates through a hashtable and returns the key as a string, whats the best way to go about this? EDIT: copied from comment Sorry if I didn't make it more clear, I'm trying to do this in Java. I've created a test class public void runprog() { hashMap.put("Butter", 50); hashMap.put("Beans", ...

How do I iterate through each element in an n-dimensional matrix in MATLAB?

I have a problem. I need to iterate through every element in an n-dimensional matrix in MATLAB. The problem is, I don't know how to do this for an arbitrary number of dimensions. I know I can say for i = 1:size(m,1) for j = 1:size(m,2) for k = 1:size(m,3) and so on, but is there a way to do it for an arbitrary number of di...

iterating over unknown XML structure with PHP (DOM)

Hi all I want to write a function that parses a (theoretically) unknown XML data structure into an equivalent PHP array. Here is my sample XML: <?xml version="1.0" encoding="UTF-8"?> <content> <title>Sample Text</title> <introduction> <paragraph>This is some rudimentary text</paragraph> </introduction> <description> <paragra...

Java Iterate Bits in Byte Array

How can i iterate bits in a byte array? ...

How to iterate over a JSON structure ?

Hello, I have the following JSON structure: [ {"id":"10", "class": "child-of-9"}, {"id":"11", "classd": "child-of-10"}]; how to iterate over it using jquery or javascript? ...

C# Iterate Over DataGridView & Change Row Color

Hello! I have a datagridview made up of multiple rows and columns. I want to iterate through each row and check the contents of a specific column. If that column contains the word "NO", I want to change the forecolor of the entire row to Red. Here is an attempt at some code so far but It's certainly not working, starting to wonder If I ...

How to access nested elements in struts2 with foreach tag ?

Hello there. I have the following problem in Struts 2. Let's assume i have a class like this class User { private String name; private String address; public String getName() { return name;} public String getAddress() { return address;} } and a list of users available on ValueStack named : users and a...

Jquery Iterate Through All Checked Boxes and Remove Class

Hello All, I'm currently using jQuery and would like some help on iterating through all "checked" checkboxes and remove a class (called "new_message") of the parent table row. I've got a basic concept, but I can't quite figure the entire thing out. Here is what I am currently using: $("#unread_button").click(function (event) { event....

How to bind i at the end of a sequence using Seq.iteri

mySequence |> Seq.iteri (fun i x -> ...) ... How do I bind i at the end of the sequence? In other words how do I bind the value representing the number of iterations iterated by iteri? Of course I could create a ref and assign i for all iterations, but I wonder if there is a more elegant way? ...

How do I iterate over the tuples of the items of two or more lists in Python?

Specifically, I have two lists of strings that I'd like to combine into a string where each line is the next two strings from the lists, separated by spaces: a = ['foo1', 'foo2', 'foo3'] b = ['bar1', 'bar2', 'bar3'] I want a function combine_to_lines() that would return: """foo1 bar1 foo2 bar2 foo3 bar3""" I admit I've already solv...

iterate Write XML problem

Hello everybody, I am new here and to PHP, i am trying to write a xml file whitch had as source a XML file. When i read the XML and use the echo command I can see al the record of the source XML. but when i want to write it to a XML file i can only see one record. I have read al lot of things already: some thing i found was the use a...

Pythonic way of iterating over 3D array

I have a 3D array in Python and I need to iterate over all the cubes in the array. That is, for all (x,y,z) in the array's dimensions I need to access the cube: array[(x + 0, y + 0, z + 0)] array[(x + 1, y + 0, z + 0)] array[(x + 0, y + 1, z + 0)] array[(x + 1, y + 1, z + 0)] array[(x + 0, y + 0, z + 1)] array[(x + 1, y + 0, z + 1)] ar...