Click here to Skip to main content
15,887,244 members
Everything / Vector

Vector

vector

Great Reads

by Clayton Rumley
There are those who think I am crazy, and this just might be the proof.
by Sergey Alexandrovich Kryukov
Another variant of the cross-platform replacement for all those office presentation applications in a single file, and now this file is JavaScript
by Arthur V. Ratz
Optimizing the performance of the large-sized matrices QR factorization and eigendecomposition, using Schwarz-Rutishauser algorithm
by Arthur V. Ratz
Compute the Levenshtein distance of literal strings effectively by using the Wagner-Fischer (two matrix rows-based) algorithm.

Latest Articles

by Nicolas DESCARTES
What are vector databases?
by Sergey Alexandrovich Kryukov
Another variant of the cross-platform replacement for all those office presentation applications in a single file, and now this file is JavaScript
by Arthur V. Ratz
Compute the Levenshtein distance of literal strings effectively by using the Wagner-Fischer (two matrix rows-based) algorithm.
by spore123
This is a fast multi-threaded quick-sort based algorithm

All Articles

Sort by Title

Vector 

24 Jun 2016 by The Zakies
in this tut we will create a technique to enable the user to control points within a drawn line, by drawing circles around points of the line , when the user clicks a circle he would control the corresponding point.
29 Jun 2016 by The Zakies
we would create Hand_tool to pan through the drawing form, and we would use a custom cursor of open and closed hands
3 Jul 2016 by The Zakies
we will continue the functionality of the hand tool with having a navigator panel which works as a map, we will also have a red rectangle which tells the user where he is actually viewing inside the whole form, also it can be moved to pan the form
20 Jun 2016 by The Zakies
Learn how to implement a tecnique of a parent form that createes and controls other forms , through the tecnique of using the tab control, also learn how to implement a menu for the tools, and how to add cutom cursor for each tool
16 Mar 2022 by honey the codewitch
Get your data on, even on platforms without a reliable STL implementation using these simple but critical classes.
23 Jun 2020 by Greg Utas
Replacing its erase() function
8 Jan 2018 by CodeBlooded
So, I what I want is to collect maximum element from each row(in a 2D vector) and push it into a new vector. And if the new vector is sorted I want the sum of all vector elements. I tried it but the code is showing error : "cannot convert 'std::vector to 'int' assignment" also, is my code...
8 Jan 2018 by Patrice T
You try to solve this problem Contest Page | CodeChef[^]. As usual CodeChef challenges are not for beginners, and unfortunately you have read the requirements too fast and misunderstood it. All details count. Someone else have asked for help, read answers given, they should help you to...
11 Sep 2016 by Emporea
So i am trying to code a program to sort and list some data. I use a vector with my class so every entry got its own object. But i realized i may want to add more tags/categorys to every entry and to store this new data i need a new variables or new functions in my class. How can i add...
11 Sep 2016 by KarstenK
I think you should do some design wor with UML to clarify what you want to code. Here is a tutorial. An easy solution is also to draw it at paper - best with a pencil.Dont knowing the type of the variables is bad style. You can do such stuff by adding a dictionary which has a key (your...
16 Sep 2022 by Arthur V. Ratz
Compute the Levenshtein distance of literal strings effectively by using the Wagner-Fischer (two matrix rows-based) algorithm.
21 Mar 2015 by Member 11544807
Hi guysmy problem is to convert bitmap to SVG in c#. I found something like this http://docs.opencv.org/2.4.2/doc/tutorials/imgproc/shapedescriptors/find_contours/find_contours.html but this didn´t solve my problem. I need to convert for example a facewith white background from bitmap to...
21 Mar 2015 by OriginalGriff
We aren't going to be able to give you an "out of the box" solution: this is not a trivial process in any way, shape or form.The problem is that Bimap, JPG, PNG, etc. files are raster graphics: they store a fixed array of pixels in various shades of red, green and blue (or hue, lightness and...
21 Mar 2015 by phil.o
SVG being an xml-based format, if you do not want to use xml, you are going to have quite a hard time :)The following post on SO could perhaps shed a light on your requirement:SO: Convert Image (JPG,BMP,GIF) to SVG[^]
22 Mar 2015 by Member 11544807
ok so now.. i need to trace that bitmap... and then vectorize it... and save as SVG... but i cant use freeware like inkscape... i need to make my own app.
5 Dec 2014 by FoxRoot
Hello everyone,I' am working on vectors. I searched lots of resources. However, there is no data about vectors in C. Basicly, I should create an object(ie. Person) which should be a vector. Each property of actual object should be a vector. Is there any idea or source to read?Thank you.
6 Feb 2018 by rafaelfinalcut10
The code below – it's a skeleton of a program operating on the dynamic collection of data. The idea is to use a structure containing two fields: the first stores the number of elements in collections, and the second is the actual collection (a dynamically allocated vector of ints). As you can...
4 Feb 2018 by OriginalGriff
As I told you when you posted this earlier today, we do not do your work for you. Deleting the question and reposting it in the hope we won't notice is not a good idea - it won't get your work done for you, but it will annoy people. Read the instructions carefully, and think about what you...
4 Feb 2018 by CPallini
Quote: int *temp; temp = new[]; Let's fix your starting point. The above statemens should be int * temp; temp = new int[col.elno + 1]; Now your temp vector as the right number of items. You have to Copy all the col.elements items into temp. Add element at the end of temp. ...
23 Apr 2016 by Member 12371341
Hi all!So I have another problem.I have to traverse the vector and print out the values using an iterator.I know you say.... how hard can that be?I thought the same so i did like this// suppose we have a vector that takes a pointer to an object of abstract class//...
23 Apr 2016 by Patrice T
for(int a = 0; a print();}Are you sure this loop don't miss the last place in the vector ?[UpDate]Quote:It goes from zero to size - 1your code stops before size-1, so it stops at size-2, check again.
23 Apr 2016 by Philippe Mori
You probably want to docout print()
10 Apr 2021 by Bhavini Amin
I am currently writing a programme to calculate the one day VaR using the historical simulation method. Within the programme I am first calculating the daily returns of the prices which the excel formula is Close_price_today -...
3 Jan 2022 by Arthur V. Ratz
Optimizing the performance of the large-sized matrices QR factorization and eigendecomposition, using Schwarz-Rutishauser algorithm
3 Sep 2014 by milkboy31415
This code transforms rotations and vectors between reference frames such as Unreal, 3d Studio Max, etc.
22 Feb 2022 by lock&_lock
(I posted this on CodeReview as well, I hope it's ok. I would love to get different perspectives & suggestion across different platforms). I am following a question on a programming challenge website (here's the original reference). What I have...
10 Sep 2017 by raushanaj5
I am trying to send images to server. Earlier I had a simple function void fileSend(const char* fpath) This function is able to send one image file to the server. But, I am supposed to send many images to the server at once, that is why I went for vector. I overloaded the previous method...
10 Sep 2017 by KarstenK
the path sound weired: string path = "C:\\Images:\\"; with the second ":" Resolve this and debug the code.Maybe the overloaded call isnt resolved as you wish. Try to rename one function.
10 Sep 2017 by Jochen Arndt
There is no clear concept in your code and you are mixing C and C++ library functions for similar tasks (e.g. using C++ and C streams for file operations). I don't see actually where and why your code fails, but here are some tips: Your code does not check for errors. You should check the...
20 Oct 2015 by Member 4581741
I have used Raphael to create a map. The map uses VML as a base for creating graphics. (http://raphaeljs.com/world/world.js) Ex: AE:...
29 Oct 2015 by Member 4581741
Nevermind, i was able to convert the latitude and longitudes to pixels(points) and convert that into SVG format.Thanks
11 Mar 2018 by Member 13720753
I do not understand this question: "In main method creates a (1) vector (not vector object) of the class type Animals.This should be of size 50" What I have tried: i have tried to create it in this way: Vector myAnimals = new Vector(50); did i do it right? Thank you
7 Apr 2017 by Member 12157883
I am building a search algorithm using OpenCV Mat where I convert the Mat to gray image and then check the pixel to sign it to walkable or not walkable with their coordinate. I used a 2D vector to create a grid of node. The Node is a class to contain information about the pixel. when I try to...
7 Apr 2017 by Jochen Arndt
There are two errors in your code: You are never calling CreateGrid() (Grid::grid is empty) The Grid::grid vectors are never allocated To fix the first error call CreateGrid() in the constructor: Grid(cv::Mat _map){ map = _map; gridx = map.cols; gridy = map.cols; ...
17 Nov 2015 by ikon95
I'm new to C++ and my question is how can I retrieve an object from the Flight to be compared to the input (flightNumber) in the main? How do I declare the attributes type in the main? The error message displays "invalid conversion of 'int' to 'Flight' in the second last line.class...
18 Nov 2015 by CPallini
Try:void Agent::delete(int flightNumber){ vector::iterator ptr; for(ptr=flightList.begin();ptr!=flightList.end();ptr++) { if( ptr->FlightNumber == flightNumber) { flightList.erase(ptr); return; } } if ((ptr)...
22 Sep 2014 by Igor-84
I use the following code for writing the vector to map container:int my_array[2];my_array[0] = 356;my_array[1] = 41; my_vector.push_back(my_array); std::map*> my_map;my_map.insert(std::pair*> (1, &my_vector));And when I try to...
22 Sep 2014 by jsolutions_uk
my_array is an array of 2 integer values, 356 and 41, all good so far ;) ...I am assuming that my_vector is declared as a std::vector ? So is a vector of pointers to integers, or in your case, I am assuming you intend it to be a vector of pointers to arrays (or rather a vector of...
31 Oct 2015 by Stefano Lodico
I'm sorry for my bad English, but it isn't my language.I've done an exercise in C++11 for University:This is a program for understanding Templates:#include #include #include class matrix{ public: matrix(int riga, int colonna){ ...
3 Jul 2015 by Member 11401516
Good afternoon,I'm here with a doubt that i am not able to overcome and i've tried a number of ways. I'm doing a program that among other things the user has to enter data about a product where the serial number has to be unique and of type char. What is happening is that when i type the 1st...
5 Jul 2015 by Daniel Pfeffer
I will answer the specific question that you asked (leaving all other errors for you to find).When calling procurarNumeroserie() for the first time, contadorProdutos == 0. This means that the loop is not executed, leaving posicao as zero. The caller sees this as an indication that the...
21 Sep 2017 by Mwater07
I would like to write a program that stores nonzero elements of 2 different vectors into 2 different linked lists with their indexes. Then would like t to calculate the dot product and displays the result. I am struggling to read in vector values with indexes into a link list. Please advice ...
21 Sep 2017 by Patrice T
The code is not complete, you should use the debugger to see what your code us doing There is a tool that allow you to see what your code is doing, its name is debugger. It is also a great learning tool because it show you reality and you can see which expectation match reality. When you don't...
31 Jul 2014 by WENzER
I am trying to write a program in C++ which should input a string array, and string should contain Employee Name Salary and Its Manager Name with comma seperated delimeterThe input will be provided following format:Mr XX, 5200000, NONEMr YY,52000, Mr. XXMr ZZ, 34500, Mr. YYThere is...
30 Jul 2014 by nv3
The best approach would be to store your entire input data in a tree structure. If you are familiar with tree-structures, this will probably the most obvious solution.As you have not chosen that path, I assume that you are not familiar with building a tree in C++. So here is an easier way to...
30 Jul 2014 by chandanadhikari
hi,for simply comparing 2 vectors you can check this out [^]hope it helps !
5 Aug 2019 by Member 14549814
I want a vector of functions that would look something like this: vector>v; but obviously this didn't work... something like this: #include using namespace std; int f1(int n){ return n*2+2; } string f2(string n){ return n+'!'; } int main(){...
4 Aug 2019 by Rick York
Here's one way it can be done. typedef UINT( WINAPI * ThreadFunc )( PVOID ); typedef struct { ThreadFunc function; PVOID argument; } OneFunction; int main() { std::vector functions; OneFunction f; // set the members of f here ...
5 Aug 2019 by Stefan_Lang
Don't do this. It's probably doable with variadic templates, but judging by your code you already have enough trouble without templates. Moreover, putting functions (or rather references to functions) into a container eliminates readability, makes your code hard to read and prone to errors. ...
12 Sep 2023 by Brennon Nevels
While I'm aware that this is just a simple thing to do, I've tried to make this into a function. While mine kind of works, I'm more interested in how other people would go about it. #include #include #include ...
11 Sep 2023 by Rick York
That is done use the erase method of the vector class : https://cplusplus.com/reference/vector/vector/erase/[^]. It can be a very expensive operation to perform if deleting from anywhere except the tail end of the vector. If deletions are going...
11 Sep 2023 by CPallini
With C++ 20, the single line std::erase(shoppingList, choice); would do the trick. See std::erase, std::erase_if (std::vector) - cppreference.com[^].
12 Sep 2023 by Greg Utas
If the order of elements in the vector isn't important, an efficient way to do this is to move the last element into the slot of the element being erased. This is how I manage the list of open sockets for the poll function, and I wrote a simple...
17 Mar 2021 by Member 15104493
Hey! I have created an array that has 50 places. When the places are full, I want it to constantly expand with 1 place in the array, but it does not work... I need to use array and can not use List.. And I can not use array.resize... Please...
17 Mar 2021 by Richard MacCutchan
Use Array.Copy Method (System) | Microsoft Docs[^].
17 Mar 2021 by OriginalGriff
The best solution is to not use an array - use a List instead. Internally, it uses an array for storage, but externally it appears as expandable. This may help as to why your solution is a very bad idea from a performance point of view:...
18 Oct 2015 by elGp
Hello there, I have a small project about creating vector shapes and manipulating with them. I stuck at creating a rotation tool. Can someone throw a quick eye at it and give me a hint how to deal with that ?
11 Dec 2021 by John Brg
I have two vectors A,B and I want to merge them to a vector C but I want to preserve any duplicates in each vector while discarding duplicates between the two. For example if I have A{1,2,3,4,2,5} and B{7,8,2,2,2,3,3} I want C to be...
11 Dec 2021 by John Brg
Well it seems std::set_union does this. Nothing else is needed.
24 Jan 2023 by Chillzy
I'm trying to convert C++ code to C and it was all fine until I got to the .push_back() function. After some research, I found out this wasn't a function in C. How do I write a function in C that replicates the uses of the .push_back() function? ...
24 Jan 2023 by Richard MacCutchan
You cannot do it easily, as this is a method of the STL vector class. So you would need to write a complete set of functions to manage whatever data you are trying to collect. Which all begs the question, why on earth are you trying to convert...
24 Jan 2023 by CPallini
Quote: ll the code is in C++ and not C, which is a problem because I work in C, due to it being better than C++ (rather structs and unions than classes and templates and whatever bs C++ has to offer). Use C++ if you can. C++ is multi-paradigm...
24 Jan 2023 by k5054
If you are using linux you can approximate a C++ vector using a dynamic memory buffer stream (aka a memstream). Here's an example of how you might go about that: #include #include int main() { int *ints = NULL; /* a...
7 Dec 2022 by Freddie Francis
This method finds all Alien objects in the AlienList object’s Vector whose humanoid field has the value false. It stores all matching Alien objects in a new Vector that is then returned from the method. The method must also remove all the...
7 Dec 2022 by OriginalGriff
This is the same question you posted 3 days ago: I need this method to return an empty vector if there are no matching alien objects[^] Please do not repost questions, it doesn't improve the chances of you getting an answer, it just wastes the...
20 Nov 2020 by whataweird
hi, this code won't compile correctly using std::sort and a struct. How do I solve this? #include #include #include #include struct StudentDataTypes { std::string name{}; int grade{}; }; int...
20 Nov 2020 by Richard MacCutchan
The sort function does not know how to sort a StudentDataTypes structure. You must provide a comparator, see functions | Microsoft Docs[^].
20 Nov 2020 by k5054
You need to tell sort how to compare the two structs. since there's no default comparison for non basic types. Do you want to sort by name or by grade, or by grade then by name, or ...? Probably the easiest way is to add an operator
21 Jun 2016 by Dennis1990
Hi,unfortunately im sitting at this problem for 4hours now, and it drives me crazy:i got an 2 vectors as a members of my class.the firstvector contains structs and the vector with the sorting informations is filled by Enums...
20 Jun 2016 by KarstenK
To achieve your own sort order you must overwrite the sorting algorithm, by overwriting the comparison operator "
24 Jun 2016 by Dennis1990
thank you for your help.i used the STL Sort Comparision Funciton and could use the Member
19 Sep 2017 by Mwater07
I am trying write C++ programs that compute the dot product of two given vectors. In vectors a and b only nonzero elements will be stored into array of structures(row and col). Each time I am getting irrelevant results. The correct result should be 50. Please advice. Thank you in advance. ...
19 Sep 2017 by Jochen Arndt
There are three errors in your code. The first two ones: You have a fixed array size of 10 for row and col but are accessing 11 elements (out of bound access) and did not initialise all elements: for (int i=0; i
19 Sep 2017 by CPallini
You are trying to complicate a simple matter. Try #include #include using namespace std; // Please note: error handling (e.g. a.size()!=b.size()) left as exercise int dot(const vector & a, const vector &b) { int dp = 0; for (size_t n = 0; n
18 Oct 2014 by joedoeuse
I am attempting to assign random numbers to some array or vectorWhen I use this method on an array it works fine, however when I use this with an vector, it will not work. // declare small vector vector smallVector(smallSize); // call helper function to put random data in...
18 Oct 2014 by Andreas Gieriet
Try leaving away the address-of operator while instantiating the function and pass the data in the template by reference.CheersAndi
18 Oct 2014 by CubbiMew
Since data is an out-parameter (you're trying to populate it within genRand and make the result available in the caller, right?), you need to take it by reference:templatevoid genRand(T& data, int size){ ...genRand(smallVector, smallSize);genRand(smallArray,...
16 Apr 2015 by Amir Hossein Farzaneh
I am initializing a vector in a class using 4 threads by passing arguments to threads: //main.cpp #include "stdafx.h" #include #include #include "class.h" using namespace std; int main() { myCLASS* classObject = new...
16 Apr 2015 by KarstenK
You can declare some data structure (struct) which holds all of your data. That can be set at thread start or as global data.It is a common practice to use pointers to that data.struct DATA{ std::vector *cluster; int* iteration;};//possible array for 4 threadsDATA...
15 Jun 2014 by hor_313
HiI've declare a vector like this: Vector vec(3);for(Vector::iterator i=vec.begin(); i
16 Jun 2014 by Joren Heit
Assuming x and y are accessible as members of your Point type, for (Vector::iterator i = vec.begin(); i != vec.end(); ++i) // srsly, what's with the post-incr in ALL code??{ int x = i->x; // or whatever type it is // do stuff}If your compiler supports the C++11...
15 Dec 2015 by Are Riff
I am learning about dynamic memory and have a question.Let say I have this class.class Elf {private: double _health = 0;public: Elf(const double &health){_health = health;}};I can create an Elf object using smart pointer like this.unique_ptr vec1 =...
15 Dec 2015 by Leo Chapiro
You are just doing this :)Vector already internally dynamically allocates when you push_back into it.If you think about something like vector * pVec = new vector (size);so you don't need it: vector is already a wrapper around the process of dynamic allocating, so...
15 Dec 2015 by User 59241
From your example I am guessing you are asking how to construct the vector of unique_ptr's to Elf and populate. Like so: vector> vec_uniqptrElf; for (auto i = 0; i (new Elf(90))); }
4 Aug 2015 by Makhno
Hi all,I'm a new member of code project and I'm not an expert software designer, therefore, please, use a simple language for your answers. Now I'm facing this problem: I have to create a dll which should be used by several clients, using either different compilers or different version of...
4 Aug 2015 by Pascal-78
I would advise you to avoid standard library in any exported method because even with the same compiler, the debug and release version of a std::vector can be different.I have write a complex interface for a project inside my company, it must be compatible with Borland C++ 2009 and VS2010.To...
9 May 2018 by Member 13816159
Hello, I am writing a program that allows users to input a music album and store them into vectors. Then the program asks the user whether to borrow it. To do that I tried using .erase of the given vector. However the vector function is defined in a constructor of a class and the modification is...
9 May 2018 by Richard MacCutchan
You have not explaine the problem. Although I suspect that your class declaration entry for Borrow1 is wrong. You have the following in your class: public: Album(); void Borrow1() {}; // Borrow1 is an empty function. }; And you later define Album::Borrow1() with a proper body. In my test this...
11 Dec 2017 by Leo Chapiro
Just try to find object vector C++, that's all!
13 Aug 2023 by Brennon Nevels
My friend and I are building a text-based game. But the problem so far is I cannot figure out how to resolve this problem. The goal was to make two functions. One to print a vector and another to find a specific element within. #include...
13 Aug 2023 by Rick York
The function should look more like this : template void printVector( const std::vector & vec ) { for (int i = 0; i
13 Aug 2023 by merano99
It seems to me that templates might not be the right way for the desired functions. I would first overload only the output operator. There are several ways to do this. Instead of the function as before, a class VectorPrinter can be created that...
14 Mar 2015 by vezo11
Hi, I want to split hexagon into triangles and get the coordinates for the each of treangle point. How i want to split hexagon, you can see in this picture.I have class triangle and class point class Triangle { public Point A { get; set; } public Point B { get;...
14 Mar 2015 by Dave Kreskowiak
Google for "C# Triangle Mesh algorithms" and you'll come up with all kinds of examples to do it.
14 Mar 2015 by _Maxxx_
If point(0) is at (x,y)then it forms a triangle with points(x,y) , (x, y+n) , (x + SQRT(n2 - (n/2)2) , y + (n/2))where n is the length of side of the triangle - which is N / 3 where N is the hexagon side length.now you have the coordinates of triangle (0,1,5) every other triangle...
21 Apr 2015 by nizam qbixx
Hi..I was doing a research related to speech recognition. So far I already able to convert a sample waveform (.wav format) to a feature vector by using MFCC which generate .mfc file. I also able to read the .mfc file but I dont know how to related it to the spectogram. Actually, I'm not sure...
27 Jun 2021 by Proton Vpn
Hello there.. I have an vector drawable that I have been using it for an ImageView inside my Project. Now I want to change the ImageView's height and width to custom dp but when i do it the content inside it also changes it's width and height....
19 Oct 2015 by Mạnh Lê
Hi guy !I want to create a vector of arrayvector cKey;BYTE keyTemp[6];memset(keyTemp, 0xFF, sizeof(keyTemp)); // Key is FFF...FFcKey.push_back(keyTemp);but, push_back function is show errorError C3074: an array can only be initialized with an initializer-listHow to...