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...
Jacky asked 8/4, 2016 at 18:16

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...
Lief asked 1/9, 2012 at 21:30

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...
Curtain asked 5/7, 2010 at 4:36

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?
Counterfoil asked 19/4, 2016 at 14:54

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() &lt...
Convexoconcave asked 12/9, 2013 at 8:52

8

Solved

So I'm trying to make a basic program to learn the basics of C++, I'm generating 100 random numbers from 0 to 100 and storing them in a vector, I am then displaying the sum, mean, median, mode, hig...
Freida asked 25/3, 2011 at 22:29

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? ...
Strachey asked 17/12, 2009 at 17:21

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] = ...
Pedaias asked 27/11, 2020 at 21:15

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 ...
Enugu asked 27/5, 2018 at 6:30

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...
Karrikarrie asked 20/11, 2013 at 19:22

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...
Forget asked 21/6, 2012 at 8:42

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/...
Laryngeal asked 2/2, 2017 at 12:38

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?
Roasting asked 8/9, 2009 at 16:40

7

Solved

x <- rep(c("A","B","C"),times=c(6,8,3)) "A" "A" "A" "A" "A" "A" "B" "B" "B&quo...
Elizabetelizabeth asked 10/11, 2023 at 12:49

11

Solved

Should I use std::sort(numbers.begin(), numbers.end(), std::greater<int>()); or std::sort(numbers.rbegin(), numbers.rend()); // note: reverse iterators to sort a vector in descending or...
Depurate asked 26/1, 2012 at 20:47

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&gt...
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; ...
Bojorquez asked 6/6, 2011 at 0:7

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...
Seaworthy asked 10/1, 2015 at 21:55

© 2022 - 2024 — McMap. All rights reserved.