Questions tagged [iterator]
An iterator is an object-oriented programming pattern that allows traversal through a collection, agnostic of the actual implementation or object addresses in physical memory. It is one of the Gang of Four's behavioral design patterns.
iterator
14,660
questions
0
votes
0
answers
20
views
Filter large sheet with gspread
Exploring source code of gspread library discovered _finder method (findall() use it under the hood) of class Worksheet just store all data from table inside variable. It seems such behavior may occur ...
0
votes
0
answers
66
views
Is there a way to limit a Impl block to implement another trait?
I have a trait
pub trait LocationProvider<T>
where T: Into<DateTime<Utc>>
{
fn get_location(&self, time: T) -> Option<Location>;
fn get_locations(&self,...
-3
votes
0
answers
55
views
Program ends abruptly iterating a 2-D vector using an iterator [closed]
I am updating a distance matrix which computes the distance between two nodes in an unweighted graph if the edge is present in the edges vector.
Edges is a 2-D vector with each element of size 2 where ...
1
vote
2
answers
94
views
How to calculate the Relative Strength Index (RSI) through record iterations in pandas dataframe
I have created a pandas dataframe as follows:
import pandas as pd
import numpy as np
ds = { 'trend' : [1,1,1,1,2,2,3,3,3,3,3,3,4,4,4,4,4], 'price' : [23,43,56,21,43,55,54,32,9,12,11,12,23,3,2,1,1]...
0
votes
2
answers
91
views
How to binary search a std::vector BUT that return a RandomAccessIterator?
I'm looking for a log2(N) way of searching a std::vector and receive a RandomAccessIterator. I want it to work exactly as std::lower_bound() but return a RandomAccessIterator instead of a ...
0
votes
1
answer
62
views
Allowing STL algorithms to swap when iterators dereference to a wrapper class (i.e. an rvalue)
I am implementing a C++ wrapper for a C library that has a "vector of vectors" container. In the C++ interface, I would like iterators to dereference not to a raw C pointer, but to a ...
-3
votes
1
answer
49
views
Rust iterator map callback issue "function is expected to take 1 argument, but it takes 3 arguments expected function that takes 1 argument"
This "do_work" function Need to insert 3 arguments, but only first argument is working. Please view image.
I also need to insert i2 and i3 variables.
Rust map callback issue - "...
4
votes
1
answer
63
views
Is a back_insert_iterator valid for the lifetime of the container?
I think I know the answer to this, but I'd appreciate a sanity check.
Does iterator invalidation apply to std::back_insert_iterators?
#include <cassert>
#include <iterator>
#include <...
1
vote
1
answer
25
views
Error on generic type within wildcard bound
I have a custom iterator interface
public interface ThrowingIterator<T, E extends Throwable> {
// matches interface of standard Iterator, but next() and hasNext() can throw E
}
and an ...
0
votes
1
answer
307
views
TypeError: newCollection[Symbol.iterator] is not a function @for Angular 17
here is my code, error happens in the @for line
<div>
<ul>
@for (paragraph of paragraphs; track paragraph) {
<li>{{ paragraph }}</li>
...
0
votes
0
answers
32
views
How to Implement a Memory-Efficient Custom Iterator for Large Files in Python?
I need to iterate over extremely large files (several gigabytes each) in Python without loading the entire file into memory. Specifically, I want to implement a custom iterator that reads and ...
3
votes
1
answer
75
views
Is it ok to double-dereference ("**itOpt") an optional iterator?
If I have a std::optional wrapped around (say) an
std::vector::const_iterator, is it safe to access the referenced
element with two consecutive dereference (*) operators?
For example:
typedef std::...
1
vote
1
answer
68
views
How to iterate over multiple collections simultaneously?
I want to loop over each element of a Vec and a BTreeMap. I'm currently doing this:
fn main() {
let mut a = std::collections::BTreeMap::new();
a.insert("a", "b");
a....
1
vote
1
answer
101
views
Reverse while iteration not going backwards
I am trying to make a reverse loop through a list using while.
I am trying the following code:
#include <iostream>
#include <list>
int main(){
std::list <int> l1 = {1,2,3,4}...
0
votes
3
answers
54
views
Looping through 2 columns and all rows in R and forming 2 new column based on their values
I've got an R Dataframe df with two columns Country1 and Country2 and a certain number of rows. I also have two vectors Continent_Europe and Continent_Africa. Every element of Country1 and Country2 ...