Vectors are sequence containers representing arrays that can change in size.

learn more… | top users | synonyms

2
votes
2answers
70 views

split string into container on char; efficiently?

Here is my single parse code for splitting a std::string on a char into a ...
2
votes
1answer
41 views

OpenMP loop parallel for loop with function calls and STL vector

I have a function initialize_path_statistics(). I have used openMP to make it parallel. I am not sure where certain lines such as ...
6
votes
2answers
125 views

Calculate Suitability Score program

I am a beginner in C++ and learning from textbook. I find it hard to jump into oops concepts as I have used C a lot. Here is an interview question I came across: Problem Statement Our ...
10
votes
2answers
159 views

Template vector struct in C11

This one review will be a little bit tricky: I was trying to implement a template Vector struct in C11. Of course, templates don't really exist in C11, so I used a ...
4
votes
2answers
140 views

Reimplementation of C++ vector

I previously attempted to make a C++ vector here, yet it was not very successful. Now I have made a basic reimplementation of it, so I'm checking that it is fine, and that I will not have to re make ...
10
votes
2answers
711 views

C++ vector implementation

I have tried to implement a basic vector type in C++, yet I am not sure if I can do anything any more efficiently. ...
3
votes
2answers
117 views

Optimizing a vector loop

Visual Studio somehow optimizes the below code to be 20 times faster (release with optimization vs. release with no optimization). What could it be doing? ...
3
votes
1answer
137 views

best way to write series of objects to a .ser file using ObjectOutputStream and read them back

I create series of objects out of Student Class and store them in a vector. I write each object in to a .ser file once it created. Then I read them back. My code is working perfectly. What I want to ...
4
votes
2answers
187 views

Merge two sorted arrays together

Please review my answer for this interview question: ...
2
votes
1answer
181 views

vector<tuple<A,B> > to map<A,B>

i have an vector<tuple<A,b> > v and want to make a map<A,B> from it i came up with 3 variants: ...
2
votes
3answers
1k views

Simple class exercise - min, max, and average of vector items

This program calculates the min and the max value and the average of the items of a vector. It's an exercise from a book so I can't change the header file. Is this code proper? sales.h ...
0
votes
0answers
61 views

Need guidance on creating an updating hash table

I'm not sure if this implementation is good enough. The function takes a vector of 1 million chars and creates a table of how many sequences pass before the next occurrence of itself. Some questions ...
3
votes
2answers
204 views

Comma-formatted STL vectors

I move back and forth between Python and C++ and I often need a nice/quick way to output STL objects to the screen for debugging purposes. I'd like the output to match the output of a comparable ...
4
votes
2answers
146 views

Template vector class

I am trying to implement a vector-like container of my own (just to gain a better understanding of how std::vector works under the hood). I've been using this as a ...
-1
votes
1answer
43 views

Refactor Python Code

I'm looking for a way to make my code more simple. This code takes a list of vectors and returns all subset of that list that sum up to another vector. For example: {'a','b','c'} is the subset ...
5
votes
4answers
750 views

C++ vectors sort ascending/descending

How can I eliminate repetition from this code? ...
1
vote
1answer
90 views

Should I call a method (i.e. size()) multiple times or store it (if I know the value will not change) [closed]

I have a function that searches the shortest vector in a vector of vectors of pointers. Which is a better way? ...
5
votes
4answers
336 views

Given a number represented as an array of digits, plus one to the number

Given a number represented as an array of digits, plus one to the number. ...
4
votes
1answer
174 views

Distance checking of normalized vectors?

I've been learning C#/XNA in an attempt to make a game for the past few weeks so maybe this is an obvious newbie thing, but here goes: I've been making a fairly simple 2D game, so I have a list of ...
4
votes
1answer
87 views

Does this code snippet follows good coding practices?

This is my first attempt to read the contents of a file that consists of strings separated by a null character. ...
3
votes
0answers
236 views

A pointer vector sorted by its member function

Ask for suggestion on a random accessed vector with allocated elements sorted by its key obtained from its member function. I use it with Qt tree view where the access, add and deletion of tree items ...
5
votes
2answers
709 views

A simple ArrayList class in Java, what are my mistakes?

I have created a simple ArrayList with some methods from the actual ArrayList in Java. I am testing this for mistakes, but I am ...
2
votes
3answers
291 views

Need advice with a simple container class with templates C++ (code layout and readability)

First of all, thanks for looking at this code. I'm a novice coder trying to learn C++ on my own so any help is much appreciated. I've been working on a simple program to output values to the console ...
13
votes
8answers
18k views

Java function to read a CSV file

I have a java function that reads a csv and returns its content as a Vector<Vector<String>>. The function seems to work as I need it, but my gut ...
3
votes
1answer
166 views

Am I doing this ray reflection correctly?

I'm am trying to reflect a ray of a triangle using Processing and not sure I got the code right. I'm using two bits of pseudo code from two locations: Intersection of a Line with a Plane from Paul ...
0
votes
1answer
217 views

remove continuous duplicate

i've made a little function for eliminate continuous duplicate from a std::vector. i have to use c++03! for example if a vector of int is composed of: 1,1,2,3,,3,1,1,2 my function shoul return ...
6
votes
1answer
194 views

Is this a good algorithm for 2D collision, or will it allocate too much memory?

I have a Rectangle class, of which I have 5-6 vectors for each instance. The main vectors are the center and color of the object, while the secondary vectors represent more or less the north, south, ...
4
votes
1answer
265 views

Vectors assignations and operations in a loop and parallelization with OpenMP

I use this piece of code to compute a short-time Fourier transform: ...
4
votes
4answers
208 views

Looking for more knowledge on how to make my C++ Vector2 class better

This is my first attempt ever to build a Vector2 class. I scoured the net for anything that might make this class more efficient but know i'm to the point where ...
16
votes
8answers
3k views

Copying 80 bytes as fast as possible

I am running a math-oriented computation that spends a significant amount of its time doing memcpy, always copying 80 bytes from one location to the next, an array of 20 32-bit ints. The total ...
2
votes
1answer
820 views

Small 3D and 4D vector utilities

I'm a hobby programmer and have started 2 month ago with C++. I had some knowledge of Python, and I learned it all through Internet tutorials. I'm looking for your help, since I don't have a tutor I ...