tagged [iteration]

Iterate over object attributes in python

Iterate over object attributes in python I have a python object with several attributes and methods. I want to iterate over object attributes. I want to generate a dictionary containing all of the ob...

22 Oct at 19:23

How to iterate over a string in C?

How to iterate over a string in C? Right now I'm trying this: ``` #include int main(int argc, char *argv[]) { if (argc != 3) { printf("Usage: %s %s sourcecode input", argv[0], argv[1]); } el...

26 May at 20:9

Is there a way to iterate over a dictionary?

Is there a way to iterate over a dictionary? I know `NSDictionaries` as something where you need a `key` in order to get a `value`. But how can I iterate over all `keys` and `values` in a `NSDictionar...

Java HashMap: How to get a key and value by index?

Java HashMap: How to get a key and value by index? I am trying to use a HashMap to map a unique string to a string ArrayList like this: Basically, I want to be able to access the keys by number, not b...

2 Feb at 22:14

How to iterate through range of Dates in Java?

How to iterate through range of Dates in Java? In my script I need to perform a set of actions through range of dates, given a start and end date. Please provide me guidance to achieve this using Java...

28 Jul at 16:58

How do I access properties of a javascript object if I don't know the names?

How do I access properties of a javascript object if I don't know the names? Say you have a javascript object like this: You can access the properties by the property name: But is it possible to get t...

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

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...

Iterating a dictionary in C#

Iterating a dictionary in C# ``` var dict = new Dictionary(); for (int i = 0; i

23 May at 11:46

iterating on enum type

iterating on enum type > [How do I enumerate an enum?](https://stackoverflow.com/questions/105372/how-do-i-enumerate-an-enum) I don't know if it is possible to do what I want to do, but I think why ...

23 May at 11:53

C# or VB.NET - Iterate all Public Enums

C# or VB.NET - Iterate all Public Enums We have a common component in our source which contains all the enums (approx 300!) for a very large application. Is there any way, using either C# or VB.NET, t...

23 May at 12:0

Allowing iteration without generating any garbage

Allowing iteration without generating any garbage I have the following code in an object pool that implements the IEnumerable interface. ``` public IEnumerable ActiveNodes { get { for (int i =...

Existing LINQ extension method similar to Parallel.For?

Existing LINQ extension method similar to Parallel.For? > [LINQ equivalent of foreach for IEnumerable](https://stackoverflow.com/questions/200574/linq-equivalent-of-foreach-for-ienumerablet) The lin...

23 May at 12:18

Best way to iterate over a list and remove items from it?

Best way to iterate over a list and remove items from it? I need to iterate over a `List` and remove items that answer a certain condition. I saw this answer ([https://stackoverflow.com/a/1582317/5077...

23 May at 12:24

Python list iterator behavior and next(iterator)

Python list iterator behavior and next(iterator) Consider: So, advancing the iterator is, as expected, handled by mutating that same object. This being the case, I would expect: to skip every second e...

4 Sep at 15:5

How to iterate over a JavaScript object?

How to iterate over a JavaScript object? I have an object in JavaScript: I want to use a `for` loop to get its properties. And I want to iterate it in parts (not all object properties at once). With a...

What is the perfect counterpart in Python for "while not EOF"

What is the perfect counterpart in Python for "while not EOF" To read some text file, in C or Pascal, I always use the following snippets to read the data until EOF: Thus, I wonder how can I do this s...

21 Oct at 10:2

Iterating through the Alphabet - C# a-caz

Iterating through the Alphabet - C# a-caz I have a question about iterate through the Alphabet. I would like to have a loop that begins with "a" and ends with "z". After that, the loop begins "aa" and...

13 Dec at 09:35

What is the fastest/safest method to iterate over a HashSet?

What is the fastest/safest method to iterate over a HashSet? I'm still quite new to C#, but noticed the advantages through forum postings of using a `HashSet` instead of a `List` in specific cases. My...

26 Feb at 19:0

How to iterate through two IEnumerables simultaneously?

How to iterate through two IEnumerables simultaneously? I have two enumerables: `IEnumerable list1` and `IEnumerable list2`. I would like to iterate through them simultaneously like: If they don't con...

28 Apr at 19:30

How to loop through key/value object in Javascript?

How to loop through key/value object in Javascript? now I want to create a `setUsers()` method that takes a key/value pair object and initializes the `user` variable. where data is like:

How to iterate through an ArrayList of Objects of ArrayList of Objects?

How to iterate through an ArrayList of Objects of ArrayList of Objects? Let say I have a class call `Gun`. I have another class call `Bullet`. Class `Gun` has an ArrayList of `Bullet`. To iterate thro...

17 Nov at 18:34

Python: Adding element to list while iterating

Python: Adding element to list while iterating I know that it is not allowed to remove elements while iterating a list, but is it allowed to add elements to a python list while iterating. Here is an e...

5 Dec at 22:37

How can I loop through a C++ map of maps?

How can I loop through a C++ map of maps? How can I loop through a `std::map` in C++? My map is defined as: For example, the above container holds data like this: ``` m["name1"]["value1"] = "data1"; m...

1 Jan at 15:36

How to loop through array in jQuery?

How to loop through array in jQuery? I am trying to loop through an array. I have the following code: Am trying to get all the data out of the array. Can some one lead me in the right path please?

How to iterate through a list of dictionaries in Jinja template?

How to iterate through a list of dictionaries in Jinja template? I tried: In the template: ``` Key Value {% for dictionary in list1 %} {% for key in dictionary %}