vector Questions
3
Solved
I'm trying to remove some elements from a vector, based on a predicate, and collecting the result. Here's a (not working) example with an expected result:
let mut v: Vec<i32> = vec![1, 2, 3,...
4
Solved
I have a vector with each element being a pair. I am confused with the syntax. Can someone please tell me how to iterate over each vector and in turn each element of pair to access the class.
std...
Frontlet asked 8/10, 2012 at 16:1
4
Solved
If I have
vector<T> list
Where each element in the list is unique, what's the easiest way of deleting an element provided that I don't know if it's in the list or not? I don't know ...
4
Solved
I'm having trouble with vector iterators. I've read in a few places that checking for null iterators isn't possible, and that the usual way to check iterators is to check it against vector.end() af...
2
Solved
I am currently working in internship on atmospheric/climate physics. I have netcdf datas from ERA5 (copernicus) that I already plotted in different maps, graphics etc...
I need to plot wind vector ...
Above asked 17/8, 2020 at 13:3
3
Solved
I am new in C++.
I need to copy a vector in reverse order to another vector.
Here's how i did it :
int temp[] = {3, 12, 17};
vector<int>v(temp, temp+3);
vector<int>n_v;
n_v=v;
reve...
7
Solved
I'm very new to C++ and Qt, but I'm very good at C#/Java.
The point is I like cross-platform, but I'm confuse with Qt. Isn't std::vector already cross-platform, doesn't Qt provide an equivalent to...
3
Solved
I have a matrix:
A<-t(matrix(
c(0, 0, 1,
0, 0, 0,
0, 0, 1,
0, 0, 1,
0, 0, 0,
1, 1, 0), 3, 6))
and I need to keep columns that appear only once. So, the expected result is just the 3rd colu...
Mayst asked 3/7, 2022 at 15:31
3
Solved
I have a vector of integers from 0-9 and need all unique possible combinations of these consecutive vector elements, including the original elements.
> vec <- 0:9
> vec
[1] 0 1 2 3 4 5 6 ...
Bedeck asked 30/6, 2022 at 10:41
4
Solved
I'm attempting to make a small program that processes INI files, for use in a later project, first by reducing its size once loaded into memory. Thus,
where vLine is a vector containing the file c...
1
I'm learning the c++ STL and it came to my attention that while most functionalities supported by std::vector and std::array (contiguous storage) are marked with constexpr, that's not the case for ...
3
Solved
I know this might overlap with the question What is a “span” and when should I use one?, but I think the answer to this specific part of the question is pretty confusing. On one hand, there are quo...
6
Solved
What is the most efficient way of obtaining lists (as a vector) of the keys and values from an unordered_map?
For concreteness, suppose the map in question is a unordered_map<string, double>...
Creative asked 13/12, 2011 at 3:28
16
Solved
If I have a vector of values and want to check that they are all the same, what is the best way to do this in C++ efficiently? If I were programming in some other language like R one way my minds j...
Clove asked 29/11, 2013 at 13:37
8
Solved
If I want to process data in a std::vector with SSE, I need 16 byte alignment. How can I achieve that? Do I need to write my own allocator? Or does the default allocator already align to 16 byte bo...
Peal asked 10/12, 2011 at 11:38
7
Solved
How to write bitset data to a file?
The first answer doesn't answer the question correctly, since it takes 8 times more space than it should.
How would you do it ? I really need it to save a lot ...
3
Solved
There are two existing questions about replacing vector elements that are not assignable:
C++ Use Unassignable Objects in Vector
How to push_back without operator=() for const members?
A typica...
Midweek asked 16/10, 2012 at 5:58
2
Solved
I am currently using Visual Studio 2022 Update 17.1.6, and I found something interesting with exporting type alias. For reasons I don't understand, when I export a type alias for some data type suc...
3
Solved
For example, I have such struct in a templated class:
struct Foo{
int data;
vector<Foo*> children;
}
And to print out the data value, I can simply do this: (let bar be a pointer to a Foo...
6
Solved
Given a bounding box, with definitions like bounds.min.(x/y/z), bounds.max.(x/y/z), and two points in 3D space (expressed as Vector3 objects), how can I determine if the line made by the two points...
17
Solved
I'm writing an inner loop that needs to place structs in contiguous storage. I don't know how many of these structs there will be ahead of time. My problem is that STL's vector initializes its valu...
Pronghorn asked 18/9, 2008 at 20:31
1
Solved
TL;DR: GCC 11.2.0 (image f7ea55625e09) + C++20 + <vector>'s std::vector<anything> cause useless output. How to get out something I can work with?
Compilation works in:
module cache
sin...
5
Given a class like this:
class Foo
{
const int a;
};
Is it possible to put that class in a vector? When I try, my compiler tells me it can't use the default assignment operator. I try to write ...
Carpogonium asked 26/5, 2010 at 22:20
3
I'm trying to create a hash of arrays of pointers to my object.
The hash key is an int for the type of the object, and the array is a list of the objects to render.
What I'm trying to do is :
unord...
Basilicata asked 18/6, 2012 at 10:51
4
Solved
Can I create an std::vector using my pre-existing data instead of it allocating new memory and copying the data?
To be clearer, if I have a memory area (either a c-array or part of another vector ...
© 2022 - 2024 — McMap. All rights reserved.