vector Questions
6
I have a struct:
typedef struct Tick {
double open;
double high;
double low;
double close;
double ema100;
} Tick;
I would like to access a property given a key:
Tick currentTick = {44.5, 4...
8
Solved
When I use resize(int newsize) in C++ for vector<T>, it means that the size of this vector are set to newsize and the indexes run in range [0..newsize). How to do the same in C# for List<T...
11
Solved
I've a vector of vectors say vector<vector<int>> of different sizes as follows:
vector<vector<int>> items = {
{ 1, 2, 3 },
{ 4, 5 },
{ 6, 7, 8 }
};
I want to create comb...
Matron asked 11/3, 2011 at 22:28
17
Solved
In terms of performance, what would work faster? Is there a difference? Is it platform dependent?
//1. Using vector<string>::iterator:
vector<string> vs = GetVector();
for(vector<...
Espouse asked 22/4, 2009 at 10:55
6
Solved
I need to create a function which appends a value to a vector and returns the index of the value that was just appended.
Example:
int append(std::vector<int>& numbers, int number){
int...
Gottwald asked 10/8, 2010 at 9:14
11
Solved
I'm using multitreading and want to merge the results. For example:
std::vector<int> A;
std::vector<int> B;
std::vector<int> AB;
I want AB to have to contents of A and the cont...
3
Solved
What is a good clean way to convert a std::vector<int> intVec to std::vector<double> doubleVec. Or, more generally, to convert two vectors of convertible types?
Dichasium asked 18/6, 2011 at 21:50
2
Solved
Is there a way of initializing a opencv cv::Mat using a vector<float> object?
Or do I need to loop over every entry of the vector and write it into the cv::Mat object?
2
Solved
Is the following code ok?:
std::vector<char> var;
size_t requiredSize;
getenv_s(&requiredSize, NULL, 0, "Something");
if (requiredSize == 0)
{
return ENV_NOT_EXIST;
}
if(var.size() <...
8
Solved
21
Solved
I have a vector of numbers:
numbers <- c(4,23,4,23,5,43,54,56,657,67,67,435,
453,435,324,34,456,56,567,65,34,435)
How can I have R count the number of times a value x appears in the vector?
...
2
Solved
I have a reference to a Vec and I want to extract a reference to exactly one element from it, and panic if there are any more elements or zero. The equivalent if I had an array would be:
let [x] = ...
7
Solved
Is there an equivalent of list slicing [1:] from Python in C++ with vectors? I simply want to get all but the first element from a vector.
Python's list slicing operator:
list1 = [1, 2, 3]
list2 ...
3
Solved
I am trying to create a new vector that is the sum of 35 other vectors. The problem is that there are lots of NA values, but for this particular use, I want to treat those as zeros. Adding the vect...
12
Solved
Does someone know the way to define constant-sized vector?
For example, instead of defining
std::vector<int>
it will be
std::vector<10, int>
It should be completely cross-platfor...
3
I have a vector drawable (category_bg) and I'm using it as a background to a FrameLayout
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/...
9
Solved
Is there a way to remove an item from a vector based on index as of now i am using subvec to split the vector and recreate it again. I am looking for the reverse of assoc for vectors?
7
Solved
x <- rep(c("A","B","C"),times=c(6,8,3))
"A" "A" "A" "A" "A" "A" "B" "B" "B&quo...
11
Solved
4
Solved
There is a method contains that can be used to check if a particular element exists in a Vec. How to check if all elements from a Vec are contained in another Vec? Is there something more concise t...
Laetitia asked 6/10, 2020 at 13:13
8
Solved
I want to check if a vector of integers has any duplicates or not, and have to return true if it does. So I try to do something like this:
vector<int> uGuess = {1,2,3,3,4,5}
vector<int>...
Olnek asked 28/9, 2017 at 20:27
1
Solved
I am looking into using Elastic KNN search feature and from what I see this is how we query ES for KNN search.
GET my-index/_knn_search
{
"knn": {
"field": "image_vector&...
Lyssa asked 9/10, 2023 at 17:21
5
I am trying to include a vector in my struct.
Here is my struct:
struct Region
{
bool hasPoly;
long size1;
long size2;
long size3;
long size4;
long size5;
long size6;
//Mesh* meshRef; ...
4
Editor's note: This question predates Rust 0.1 (tagged 2013-07-03) and is not syntactically valid Rust 1.0 code. Answers may still contain valuable information.
Does anyone know how to create mut...
Citizenship asked 27/10, 2012 at 18:9
4
Solved
I was reading Stroustrup's blog on c++ (http://isocpp.org/blog/2014/12/myths-3) when I found an intersting piece of code:
void do_my_sort(vector<double>& v)
{
sort(v,[](double x, double...
© 2022 - 2024 — McMap. All rights reserved.