Most voted "iterator" questions
49 questions
Sort by count of
-
27
votes12
answers28737
viewsWhat are the ways to iterate an array in PHP (without foreach)?
Before I am censured by the question, notice beforehand that the purpose of it is simply to level curiosity. I know that the foreach is the most suitable means for this. But I would like to know the…
-
16
votes1
answer1315
viewsHow does Spliterator work in Java 8?
In Java 8 (which was released in March 2014), there is a new interface called Splitter. She has a purpose similar to Iterator, but is designed to perform parallel iterations. However, even after…
-
12
votes2
answers5293
viewsWhat is an Iterator?
Studying the STL in C++, I almost always come across the term iterator, example: std::vector<int>::iterator it; What is the function of a iterator?…
-
9
votes2
answers298
viewsHow to check if a value is iterable by foreach in PHP?
In PHP, not just arrays are eternal, but also some specific objects. For example, objects that implement the interface Iterator or IteratorAggregate. Another example is stdClass and ArrayObject,…
-
8
votes1
answer104
viewsWhat is the Emptyiterator class for?
In the documentation of PHP, has a class called EmptyIterator When I look at the method documentation EmptyIterator::rewind(), there is written: No Operation, Nothing to do. (No operation, nothing…
-
8
votes1
answer439
viewsWith doing an iterator/Generator in javascript?
In PHP, we have the Iterators and the Generator. Iterator example: $f = new FileSystemIterator(__DIR__); foreach($f as $file) { echo $file->getFilename(); } Example Generator: function…
-
6
votes2
answers959
viewsHow to compare the value of a Hashmap<key, value> with a variable?
I have a HashMap aluno<Integer, Float>, where the key Integer will be the student’s registration number, and the amount Float will be the student’s grade. I got the grade average using the…
-
5
votes2
answers714
viewsHow do I know if a value is eternal in Python?
How can I check in Python if a certain value is eternal? What determines that a particular type can be eternal? For example, how to find out this in the case below? a = 1 b = 'Uma string' c = [1, 2,…
-
5
votes1
answer259
viewsWhy not iterate a hashmap?
I was doing a project and one of my colleagues mentioned that iterate hashmaps is something to avoid and instead of using hashmap should wear Linked lists. However I think the versatility of the…
-
5
votes1
answer944
viewsHow to switch between the next element and the previous element of a Listiterator with just one click?
I have a list of words stored in my variable listaPalavra already initialized with values, of type ArrayList<T>: listaPalavra.add("Palavra 1"); listaPalavra.add("Palavra 2");…
-
4
votes10
answers29077
viewsScroll through an Array and check if any element is empty
Is there a native PHP function to traverse a array and check if any element of this array is empty null? Observe the code below: if(isset($_POST['btnCriaModelo'])){ $instArray =…
-
4
votes1
answer684
viewsWhat would be Iteration?
In a question I asked, I questioned what it was and what would be the function of ListIterator, then came the term iteration, what would that be? Link to question…
-
4
votes2
answers110
viewsIs it possible to use Async Generators with the ES5 syntax?
For example, the code below that creates a async Generator: async function* iterate() { yield 1; yield 2; yield 3; return null; } Could be used with the syntax for await...of: for await (const…
-
3
votes2
answers64
viewsHow to iterate over a huge amount of records with scala sorm
I want to iterate over a lot of records from a table with sorm, but I want to do it in a memory efficient way. Today I use this code: Db.query[Items].whereEqual("title", someTitle).fetch.foreach {…
-
3
votes2
answers93
viewsHow to correctly iterate all records of a structure with multiple depth levels in Rust?
I would like to know how to iterate correctly in Rust all the results contained in a data structure so arranged: struct Node { id: i64, nodes: Vec<Node> } Where records entered in this…
-
3
votes1
answer104
viewsDealing with nested objects (nesting) using a ORM
Let’s assume that in a system for a bus company I have entities: Line, car and travel. Each one has three classes: The entity itself, class Linha extends Model { protected $id; // outras…
-
3
votes1
answer61
viewsDifferent ways to create an iterator for values
Is there any difference between creating a iterator for the values of an array using these two forms? let myIterator = arr[Symbol.iterator]() let myIterator2 = arr.values() I’ve run some tests, and…
-
3
votes3
answers85
viewsHow does variable p work in this code?
I don’t know how the variable p of loop while is working on that code. If the variable p is the iteration variable, because the exercise also uses a variable p within the while to store the s.find(…
-
3
votes1
answer179
viewsPrinting tabular form lists with generators
I have a list that represents 5 one-month periods with 31 days, and each period contains daily target values for a retail seller. Only for elucidation purposes would the empty structure be like…
-
2
votes2
answers674
viewsHow to use an iterator twice within an understanding?
Let’s say I have a list: lista = [(1,1), (1,2), (1,3), (2,6), (2,4), (3,1), (3,2)] And I want to know the maximum and minimum values of the second element, grouped by the first. That is to say: {…
-
2
votes1
answer122
viewsTie problem for
I’m having a problem and I can’t identify it in my code, I have a for with 60 iterations, and it’s falling in if’s when I identify it (i in this case) is divisible by 5 or 3 only in the first…
-
2
votes2
answers323
viewsPython accumulator list
I am developing a function that takes 3 parameters fctn(Function, list, element) and that it has to return a list with the intermediate states of the accumulator, as in the example below:…
-
2
votes2
answers122
viewsString comparison
Problem : I have to get the object that displays the content in the English language ( lang == en ) But depending on the search performed the order of the languages comes completely different and I…
-
2
votes2
answers91
viewsHow do iterators created from lists rescue "random" values in Python?
I’m studying iterators and generators in Python, and I was intrigued by a question, and I can’t find the answer to that anywhere. When we create a Python generator through a generating expression…
-
1
votes1
answer247
viewsHow to manipulate iterator position
I need to compare all the elements of a list 2 a 2 am doing as follows: List: 1, 2, 3, 4. Comparison: 1 and 2, 1 and 3, 1 and 4, 2 and 1, 2 and 3... I’m using it as follows: Iterator<Policie>…
-
1
votes0
answers44
viewsPass vector start and end to Sort function using c++ method overload
I want to access using overload using node which is a base class object method getInicioVetor and getFimVetor within the daughter class, I wonder if there is a way to do this? I tried so only that…
-
1
votes2
answers256
viewsAdding a value to an object array with reduce
I have an array of objects that follow this format: [ { name: 'Batata', points: 23, }, { name: 'Pizza', points: 50, }, { name: 'Tacos', points: 60, }, ]; I want to go through this array and get the…
-
1
votes1
answer62
viewsThis is the iteration of a nested loop
How to use generators/iterators to achieve the generic iteration of a nested loop? I have the following function implemented in an extremely inefficient way. from pprint import pprint def center(i,…
-
1
votes1
answer78
viewsHow to iterate inside a list that is inside another class?
I wonder if it is possible to iterate a list that is in another class. On a social network, every user has a list of posts, but this list is defined only in the class User how to iterate inside it ?…
-
1
votes1
answer58
viewsProblems tried to change function next()
I need to do this class-related activity, I don’t know much about it yet and I’m a little confused. Write a Python class with a custom iterator, when the next() function is called, it should return…
-
1
votes0
answers19
viewsSlow iteration with pandas
I am using the following code to generate all chords of up to 6 elements, with 12 possible notes for each element. Then the amount of chords generated should be : (12*12*12*12*12*12) +…
-
0
votes1
answer43
viewspq the input x iteration DOES NOT interfere with the while loop x iteration, where it is the same variable?
I am learning programming logic with Python and I don’t understand how the input x DOES NOT interfere with the iteration of the x from the while loop, which is the same variable. Please explain to…
-
0
votes2
answers66
viewsUsing a map to store 1 ID for N values?
EDIT for lack of details, I have answered the question here. The question has been flagged and a moderator will delete it as soon as possible, thank you. I have the following Ids and values…
-
0
votes2
answers1542
viewsSum of Integer Numbers in a txt File
I have two txt files that contain only numbers (number per line), so I want to add line 1 + line 1 so successively until the last line of each file. Each file has the same line number. **In this…
-
0
votes1
answer141
viewsProblem with Iterator Map C++
the program for a URI exercise hangs (as in infinite loop) when the input (double) is different from an integer or decimal number that is not something with a middle (e.g.: 55.5). I have tried to…
-
0
votes1
answer74
viewsDoublyllist C++ // Insert value at index position (with iterator)
My insert function is correct, but I’m having memory Leak because when I debug, temp->prev->prev was pointing to nullptr instead of pointing to the rest of the list, when it has 3+ elements.…
-
0
votes2
answers307
viewsLoop in time interval
I need to go through an hour interval to assemble a grid with schedules. Example: range 08:00 to 10:00, adding 30 minutes. Forming a grid like this: 08:00 08:30 09:00 09:30 10:00 I’m trying like…
-
0
votes1
answer1609
viewsIterate in multiple text files
Good afternoon. I have the following goal: I have a series of text files and I want to create a script to iterate over all of them and count how many times certain strings appear in them. I was able…
-
0
votes1
answer82
viewsHow to read the following code in python?
I found a code in Python, but I’m not getting how it works. from itertools import permutations n = 8 cols = range(n) contador = 0 for vec in permutations(cols): if n == len(set(vec[i]+i for i in…
-
0
votes1
answer399
viewsHow to get the answer to enter immediately after the question?
I have a form and I want to send the questions and answers to a database. I took the question in text form and sent it to a field input Hidden and I want to put the question and the answer in the…
-
0
votes0
answers181
viewsWhat is an iterator?
In PHP , when I need a certain class to have a certain behavior in the call foreach, i implement an interface called Generator. In Python seems to exist as well __iter__, that changes the behavior…
-
0
votes1
answer583
viewsC++ While iterator skipping Cin.getline reading
I am starting in C++, during some tests I noticed that after the second iteration of while the Cin.getline command was not read displaying the line after it. I don’t understand what happens. Follow…
-
0
votes0
answers116
viewsStd::Begin and Std::end iterators in the circular list context
The Std::list class creates a circular list. When I create an iterator to go through it I come across an ambiguous situation, which I exemplify: #include<iostream> #include<list> using…
-
0
votes0
answers16
viewsArgument does not support iteration. How to resolve?
I am trying to apply zip to the x, y and z lists, but when running the program I get the following error: izip argument #1 must support iteration. Can someone help me fix my mistake? from…
-
0
votes1
answer2511
viewsHow to loop a dataframe by conditionally removing lines and restarting the loop in a recalculated dataframe at each removal?
Hello, I am performing some data processing and I need my algorithm to perform the comparison between two lines and remove the worst one, according to some conditions. Each time the algorithm…
-
0
votes2
answers172
viewsHow to access an attribute in a Java Arraylist?
I created an application that receives some data and gathers in a ArrayList of a class that is in another package. How do I recover an attribute that is private by getter that is in the other class…
-
-1
votes1
answer22
viewsHow to iterate an array a certain number of times in PHP in Codeigniter?
I have 2 arrays, a blank( let’s call tenStatesArray) that I want to contain 10 values and another containing 26 values( let’s call statesArray). How to pass the first 10 elements of this array…
-
-1
votes1
answer61
viewsWeb Scraping iterator taking only elements with odd index
was making Webscraping from a sales page of cars and for some reason while iterating the data to collect the Mileage data round the iterator simply repeated the items, ie : 27000 27000 48000 48000…
-
-3
votes1
answer23
viewsForce the user to answer a valid alternative in a multiple choice Python question system
The code below works well, but I would like it to ask the specified question again if the user does not type one of the three available alternatives. perguntas = { 'Pergunta 1': { 'pergunta':…