Questions tagged [vectors]

Vectors are sequence containers representing arrays that can change in size. For questions about geometric or algebraic vectors, use [coordinate-system] instead.

Filter by
Sorted by
Tagged with
13
votes
1answer
1k views

Comparing std::vector<bool> to std::vector<char>

A recent comment to an answer of mine here on Code Review brought up an interesting point. The comment was that one should use std::vector<char> over ...
8
votes
4answers
307 views

An alternative vector

Based on this question (as a starting point) and a couple of other questions about rewriting vector in C++, I am planning to write another blog article to show the best way (or more precisely, the ...
11
votes
3answers
788 views

C++ Vector The basics

Following on from my two previous posts. An alternative vector An Alternative Vector (Copy Assignment Operator) I have written a detailed blog about how to write a minimal vector like class. This ...
11
votes
2answers
8k 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. ...
11
votes
5answers
2k views

A simple program with trains and inheritance

Here it is my program. I'm especially worried about the main because I know that one must be careful while instancing vectors of "inherited" objects. The code I have works fine (as far as I can see) ...
8
votes
1answer
175 views

An Alternative Vector (Copy Assignment Operator)

This is a continuation of An Alternative Vector, taking a closer look at the copy assignment operator. In the following code, I am only posting the new version of the copy assignment operator; all ...
6
votes
3answers
323 views

Simplified implementation of std::vector in C++

I implemented a simplified version of a C++ std::vector/ArrayList learning from this link. From it, I tried to write an ...
3
votes
2answers
206 views

Code for calculating the books dispatched

Recently I came across this, here is an excerpt from it, This is another problem about Indraneel's library. His library has one long shelf. His books are numbered and he identifies the books by ...
17
votes
2answers
544 views

How to speak Brainfuck: for beginners

The following code transforms multi-line input into the the Brainfuck equivalent. One line turns into one program. The resulting programs are split by newlines for readability. Brainf.cpp ...
11
votes
1answer
377 views

Vector implementation, which received unhelpful negative feedback from professor

I've just finished a homework assignment to implement a simple Vector class. -Kindly ignore the following two paragraphs if you don't want to read someone whining about their professor Yadda, yadda,...
7
votes
2answers
1k views

Sorted vector (aka flat_set) for objects (pointers) with custom embedded key (functor used)

BEFORE YOU READ: this link should be included when you just don't like the format of the question and for those that read this question for the first time, the link may give you the idea what happened ...
5
votes
1answer
628 views

Implementation of std::vector class

I decided to implement the std::vector class in C++, and was wondering if I had done everything correctly. When I mean 'correctly', I mean that the code is ...
5
votes
2answers
275 views

Simple expandable vector in C

I'm getting tired of reading templated c++ code so I am dipping my feet in c. Here is a small, not full, implementation of an expandable vector. Right now I need only ...
3
votes
3answers
120 views

Generic vector class, follow up

This is a follow up from a post I made here. I am creating a generic vector class. I have changed the code around considerably since I had so many errors (decided to just re-do it from scratch). I ...
3
votes
2answers
1k 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 ...
2
votes
1answer
2k views

Vector-like custom container with improved insert performance

I rolled a little container class (just for couriosity) which was meant to be able as a vector replacement in some cases. (Whoever wonders about the lack of move semantic etc, I just left it out due ...
2
votes
2answers
1k views

Using std::vectors to store textures

I need to write a TextureManager class which stores Texture objects; the problem is I'm using an ...
2
votes
1answer
270 views

Auto-resizing array, that accepts negative indexes

I've been coding a helper container template to contain tiles in 2D games. What I figured out I would like when writing code for my games is forgetting all resize stuff, allowing negative indexes (for ...