Skip to main content
The 2024 Developer Survey results are live! See the results

New answers tagged

11 votes
Accepted

Optimized data structure mapping finite set of integers to values in C++

Design review You are massively over-complicating the problem You call it a map, and you talk about using integers as keys. But… in reality, because your keys are small, you are just using indices. So ...
indi's user avatar
  • 12k
4 votes

Optimized data structure mapping finite set of integers to values in C++

range check There's no provision for validating key against N, not even in a debug build. ...
J_H's user avatar
  • 30.8k
4 votes

Implementing Intersections data structure that is able to hold a container of multiple types that maintains order in C++

Inconsistent use of precision Some of your classes are templated on the type of coordinates, however in other places you hardcode float. Make sure you are ...
G. Sliepen's user avatar
  • 58.8k
3 votes

TypeScript Number Set

These add and remove: ...
user555045's user avatar
  • 10.2k
1 vote

TypeScript Number Set

I'm afraid I do not yet see the motivation for this code. Raw floats are commonly serialized in hexadecimal format. Stripping trailing hex zeros, to give shorter strings, seems like it would go at ...
J_H's user avatar
  • 30.8k
21 votes
Accepted

Simple Container Class

Advice for learning Don’t do this. The container you are trying to implement is std::vector. You don’t call it that, and you never say explicitly that ...
indi's user avatar
  • 12k
4 votes

Simple Container Class

Naming things While Container is indeed a container for objects, that name is too generic. It matters what kind of container it is: is it like a ...
G. Sliepen's user avatar
  • 58.8k
6 votes

Simple Container Class

Use std::copy instead You don't need to implement CopyData. You can use std::copy to copy ...
JimmyHu's user avatar
  • 5,444

Top 50 recent answers are included