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.

5 votes
2 answers
157 views

constexpr friendly vector with static storage and no allocation

My take 2 on constexpr friendly StaticVector. If the value_type is trivial, it can be user in constexpr functions normally. If the value_type is not trivial, it uses placement new / destroy and ...
Nick's user avatar
  • 1,656
6 votes
2 answers
122 views

ADT vector in C++

I have created a vector ADT, and this is a brief code for all of you. I will further add some more methods in it. Kindly review my below code: ...
user288615's user avatar
6 votes
1 answer
311 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
4 votes
3 answers
448 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
130 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
  • 31.9k
2 votes
3 answers
145 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
  • 139
1 vote
1 answer
193 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
  • 31.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
241 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
  • 222
-2 votes
1 answer
98 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
  • 222
4 votes
2 answers
614 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
195 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
470 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
  • 381
4 votes
1 answer
670 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

15 30 50 per page
1
2 3 4 5
22