vector Questions
11
Solved
Since
they are both contiguous memory containers;
feature wise, deque has almost everything vector has but more, since it is more efficient to insert in the front.
Why whould anyone prefer std:...
3
I have a struct NotificationOption and another struct NotificationOption2 as well as an implementation for From<NotificationOption> for NotificationOption2.
I'm would like to convert Vec<N...
Phytobiology asked 16/12, 2020 at 18:23
5
Solved
I would like to create an empty vector and append to it an array in Julia. How do I do that?
x = Vector{Float64}
append!(x, rand(10))
results in
`append!` has no method matching append!(::Type{...
13
Solved
Is there a good way of differentiating between row and column vectors in numpy? If I was to give one a vector, say:
from numpy import *
v = array([1,2,3])
they wouldn't be able to say weather I me...
2
Solved
I would like to know what's the best practice to remove an element from a vector in C++.
I have seen many times people using std::remove to find and delete the element, and then using erase to rem...
10
Solved
I've been doing a basic program to find the max, min, median, variance, mode etc. of a vector. Everything went fine until I got to the mode.
The way I see it, I should be able to loop through the v...
Submarginal asked 21/2, 2012 at 1:33
6
Solved
Context
I have a case where multiple threads must update objects stored in a shared vector. However, the vector is very large, and the number of elements to update is relatively small.
Problem
I...
Danidania asked 1/5, 2019 at 16:40
16
Solved
I need to determine the angle(s) between two n-dimensional vectors in Python. For example, the input can be two lists like the following: [1,2,3,4] and [6,7,8,9].
6
Solved
Lately I've been asked to write a function that reads the binary file into the std::vector<BYTE> where BYTE is an unsigned char. Quite quickly I came with something like this:
#include <f...
Alfy asked 28/2, 2013 at 14:45
3
Solved
I want to write applications in JavaScript that require a large amount of numerical computation. However, I'm very confused about the state of efficient linear-algebra-like computation in client-si...
Minny asked 21/3, 2017 at 2:51
2
Solved
This website implies that clearing a vector MAY change the capacity:
http://en.cppreference.com/w/cpp/container/vector/clear
Many implementations will not release allocated memory after a call
...
Crocein asked 27/8, 2013 at 14:2
3
Solved
In the proposed C++20 (The One) Ranges TS, what is the proposed method for converting the view into a std::vector?
The following code does not compile:
int
main() {
std::vector<float> va...
6
Solved
10
Solved
vector<int> v;
v.push_back(1);
v.push_back(v[0]);
If the second push_back causes a reallocation, the reference to the first integer in the vector will no longer be valid. So this isn't safe...
Erbium asked 13/9, 2013 at 14:27
27
Solved
I need to take a C++ vector with potentially a lot of elements, erase duplicates, and sort it.
I currently have the below code, but it doesn't work.
vec.erase(
std::unique(vec.begin(), vec.end()...
Mirepoix asked 25/6, 2009 at 0:28
2
Is there any way to quickly extract SVG assets on a website including SVG HTML paths back to SVG files. Any apps, dev tools, extensions that lets you do this?
Toback asked 7/1, 2018 at 11:47
4
Solved
How can I check whether the first "n" elements of two vectors are equal or not?
I tried the following:
#include <iostream>
#include <vector>
#include <iterator>
using namespace ...
5
Solved
I have a character vector of a certain length (that should not be changed) like this:
my.vec <- rep("free", 40000)
What I need to do now is the following:
I need to loop 22 through ...
Susuable asked 23/2 at 10:39
4
Solved
When I try to initialize a vector of ints, I always get this error:
expected ';' at end of declaration
I used the original code from "C++ Primer":
vector<int> v{1,2,3,4,5,6,7,8,9}...
5
7
Solved
Goal: from a list of vectors of equal length, create a matrix where each vector becomes a row.
Example:
> a <- list()
> for (i in 1:10) a[[i]] <- c(i,1:5)
> a
[[1]]
[1] 1 1 2 3 4 5...
5
Solved
I've started learning C++, so I don't know in my lack of knowledge/experience why something so seemingly simple to a rookie as what I'm about to describe isn't already in the STL. To add a vector t...
Chorale asked 16/6, 2011 at 1:38
10
Solved
I'm using Python+Numpy (can maybe also use Scipy) and have three 2D points
(P1, P2, P3);
I am trying to get the distance from P3 perpendicular to a line drawn between P1 and P2. Let P1=(x1,y1)...
4
Solved
I'm using a vector of pointers to objects. These objects are derived from a base class, and are being dynamically allocated and stored.
For example, I have something like:
vector<Enemy*> En...
3
Solved
The tutorial shows some very basic examples of pattern matching, such as matching over an integer to emulate a c-style switch statement. The tutorial also shows how to do basic destructuring over a...
Macfarlane asked 14/2, 2012 at 19:16
© 2022 - 2024 — McMap. All rights reserved.