Skip to main content
Filter by
Sorted by
Tagged with
3 votes
2 answers
232 views

I see many places in public repositories, where the first and last iterators of std::vector/std::string/std::string_view are converted into pointers using the combination of &* operators. In ...
Fedor's user avatar
  • 24.7k
0 votes
2 answers
130 views

Situation: A method that validates its arguments and returns an iterator; public static IEnumerable<double> Range(double startingValue, double step, int count) { // I would really like this ...
Joachim J's user avatar
  • 204
2 votes
1 answer
154 views

I have 2 maps using BidBook = std::map<float, int, std::greater<>>; // price -> qty using AskBook = std::map<float, int, std::less<>>; I have a struct that contain iterator ...
Huy Le's user avatar
  • 1,979
2 votes
1 answer
101 views

So i'm working on some homework related to fixing som buggy code when i ran into an interesting problem. I don't think it was one of the indended bugs because the lecturer was confused by it as well. ...
Tuned Rockets's user avatar
0 votes
0 answers
37 views

I have some code that splits a string and then does some processing on each part of the string, before returning Vec of values based on each segment. By default, the code should split the string by ...
Elliot Hatch's user avatar
  • 1,220
1 vote
1 answer
80 views

I am trying to understand the behavior of iterators in Python, particularly when using the copy.copy() and copy.deepcopy() functions. I have the following script: import copy my_list = ["a",...
shannu_boi's user avatar
4 votes
2 answers
220 views

My problem is the following : std::vector<struct pollfd> vec = { ... }; // Actually a member variable on a Server object for (auto iter = vec.begin(); iter != vec.end(); ) { if (...
Azyrod's user avatar
  • 151
1 vote
1 answer
130 views

I’m using shadcn/ui with Radix UI’s Collapsible to make a collapsible filter section. Wrapper component: import { ReactNode, useEffect, useState } from "react"; import { Collapsible, ...
musketeerdt's user avatar
4 votes
2 answers
183 views

In the C++26-adopted proposal p2542, i.e. std::views::concat, there is a confusing statement: The member typedef-name iterator_category is defined if and only if all-forward<Const, Views...> is ...
xmllmx's user avatar
  • 44.6k
0 votes
3 answers
211 views

If vectors are stored contiguously, as long as they are not made smaller or reallocated, any iterator pointing to an element within it should be valid. The following code would be defined: #include &...
BadUsername's user avatar
0 votes
2 answers
82 views

Suppose you had a programming language in which all variables are immutable. Modifying iterables could be accomplished by providing a magic variable that is immutable during an iteration step, but ...
Armin Repsold's user avatar
1 vote
1 answer
78 views

I have x_min and x_max, both i16 and x_coordinates, which is a Vec<i16>. Now, I want to check whether every x_coordinate lies between x_min and x_max. I came up with the following solution, ...
Naitik Mundra's user avatar
2 votes
1 answer
194 views

While standard algorithms should be as optimized as possible based on the iterator category, it seems to me like a lot of performance is left on the table by not being able to consider the underlying ...
Dominik Kaszewski's user avatar
2 votes
2 answers
70 views

I have code analogous to: struct L { length: usize, count: usize, } impl L { fn iter(&self, ns: impl Iterator<Item=usize>) -> impl Iterator<Item=usize> { ns....
aleferna's user avatar
  • 141
-3 votes
1 answer
109 views

Why do we return self in the iter method when we define the next method in the iterable and iterator classes? This topic was taught in the course, but it was hard to understand and I didn't understand ...
Samyar's user avatar
  • 1
4 votes
2 answers
153 views

#include <vector> class MyContainer { public: std::vector<int> data; // begin() only defined for rvalues auto begin() && { return data.begin(); } auto end() &&...
Ashcoll Ash's user avatar
-2 votes
2 answers
92 views

I'm not sure why I can iterate over an object that is not an iterator? >>> import spacy >>> nlp = spacy.load("en_core_web_sm") ...
robertspierre's user avatar
0 votes
2 answers
58 views

The following code works: fn do_it_fun<I>(words: Vec<&str>, inputs: I) where I: AsRef<[&'static str]> { for word in words { if inputs.as_ref().into_iter()...
gust's user avatar
  • 965
4 votes
2 answers
135 views

I know I can use a template to make a constructor which accepts any type of iterator like this: struct Thing { std::vector<int> integers; std::list<std::string> strings; template &...
catlover2's user avatar
  • 295
2 votes
2 answers
186 views

Does the standard require that operator->() is defined for non-contiguous past-the-end iterators? Background: Regardless of the iterator category, it is allowed for operator*() to exhibit ...
Sven Sandberg's user avatar
0 votes
2 answers
184 views

I am struggling to find a clean/idiomatic approach to partition an iterator into a fixed number of sub parts based on Enum variants. Example enum State { A(A), B(B), C(C), } let states = vec!...
rhalameddine's user avatar
4 votes
1 answer
103 views

The basic problem is that I need to output all matches of a regex within a file, but there's a few properties that make a solution tricky: The file could be very large, so the whole file cannot be ...
EarthTurtle's user avatar
-2 votes
1 answer
79 views

I frequently would like to iterate over a view of some underlying data structure, e.g. a backwards iteration or only a slice of a list. The Java standard library has some support for multiple iterator ...
Taren's user avatar
  • 32
1 vote
1 answer
152 views

A while back I ported some of the C++ stdlib containers to environment where stdlib was not available. While iterators for contiguous and node-based containers were easy, I was stumped how to ...
Dominik Kaszewski's user avatar
2 votes
1 answer
101 views

In libstdc++ there is the following code: class common_iterator { ... [[nodiscard]] constexpr decltype(auto) operator*() { __glibcxx_assert(_M_index == 0); return *...
phinz's user avatar
  • 1,647

1
2 3 4 5
301