Skip to main content

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.

6 votes
1 answer
265 views

C++ static vector revised implementation

This is a revised and expanded implementation of the original static_vector implementation based on the various suggestions and corrections from the kind people who reviewed the original version.The ...
ALLAN ZHANG's user avatar
12 votes
4 answers
2k views

C++ static vector implementation

This is my custom static vector implementation similar to Boost’s StaticVector. Basically the idea is that the container should have a fixed compile time capacity, ...
ALLAN ZHANG's user avatar
0 votes
0 answers
38 views

Autocorrelation of a vector series (2)

Related: Autocorrelation of a vector series The given C# source code computes the autocorrelation of a vector series using a Fast Fourier Transform. Can you review this code for correctness? ...
user366312's user avatar
3 votes
1 answer
339 views

First dynamic array in C

I am new to C and have been learning it for about a month now. This is my attempt to implement a dynamic array. My code works, but i don't know whether or not it leaks memory. But my code works as I ...
Logeshwaran K's user avatar
1 vote
1 answer
101 views

Bit vector in Java supporting O(1) rank() and O(log n) select() - follow-up

(This post is the continuation of Bit vector in Java supporting O(1) rank() and O(log n) select(). It resides here (version 1.0.1).) Basically, I have implemented everything harold suggested, except ...
coderodde's user avatar
  • 28.9k
2 votes
3 answers
111 views

A dynamic array with an iterator compatible with std::sort

I wrote a Vector (dynamic array) class with an iterator usable with std::sort() . It seems to pass my tests. I wondering about the issues one can spot on this ...
KcFnMi's user avatar
  • 119
1 vote
1 answer
157 views

Bit vector in Java supporting O(1) rank() and O(log n) select()

Introduction I have this GitHub repository (version 1.0.0.). It implements a rank(i) operation in \$\Theta(1)\$ time, and ...
coderodde's user avatar
  • 28.9k
13 votes
5 answers
3k views

Dynamic array of int in C

This is my first C program I just wrote in like 30 minutes and I was wondering if you could give me any pointers on ways to improve this. I'm decent at programming (around 5 years experience), but ...
Zachiah's user avatar
  • 233
1 vote
1 answer
211 views

Positive Segments

I'm trying to solve the following question: You have an array A of size n, containing −1 or 1 only, and s segments (not necessarily different). Each segment is defined by 2 integers li and ri (1 ≤ li ...
driver's user avatar
  • 232
-2 votes
1 answer
56 views

Market Portfolio Binary Search Tree [closed]

I'm trying to solve the following problem here: First line of input contains the number of days D. The next d lines contains a character c and a number x. If c is B, then buy stock . If c is S, then ...
driver's user avatar
  • 232
4 votes
2 answers
589 views

O(nlogn) Lexicographically minimal rotation code but tle on this particular case

Based on a small suggestion here , this code tries to find lexicographically minimal rotation (question) by successively comparing two adjacent substrings in the very left , that can potentially give ...
Aryaman 's user avatar
4 votes
1 answer
167 views

C++ custom vector class implementation

I've developed a custom vector class in C++, complete with functionalities like assignment, push_back(), emplace_back(), pop_back(), clear(), and size(). I would greatly appreciate any feedback on ...
Jacob's user avatar
  • 131
8 votes
2 answers
384 views

C++ std::vector Implementation

Implementation of the vector class in C++ for learning purposes. Tried to implement interesting parts from the API shown on cppreference.com, but some elements like ...
jdav22's user avatar
  • 361
4 votes
1 answer
543 views

C23 Vector Macro Implementation

I'm trying to implement a simple type-generic Vector with macros using the newest features of C23. Looking for any advice about macro design and pitfalls because I generally avoid macros at all costs. ...
Biggs's user avatar
  • 143
1 vote
2 answers
62 views

Implementing a function that takes in 2 collections of strings and compares them as if they are unordered in Rust

I'm new to Rust and I would like to implement a function to compare 2 collections of strings. The function should compare them as if they are unordered. In Python, I would implement something like ...
James's user avatar
  • 13

15 30 50 per page
1
2 3 4 5
22