Questions tagged [reinventing-the-wheel]

For when you know you are reinventing the wheel, but are doing it anyways. Questions with this tag involve code that is already fully implemented (such as from a library).

Filter by
Sorted by
Tagged with
17 votes
2 answers
5k views

It's Friday! - Zeller's Congruence Revisited

A couple of date-related questions have come up recently, and on both occasions I have been taken back to my 'early' days where one of my first forays in to programming involved implementing Zeller's ...
rolfl's user avatar
  • 97.3k
11 votes
1 answer
2k views

C++ : B-Tree in C++20 (+Iterator support)

I wrote a B-Tree implementation in C++20, based on my previous Red-Black Tree implementation. Unit Test Demo : https://wandbox.org/permlink/Brw6TgAhdy89OIyj Any feedback will be welcomed! ...
frozenca's user avatar
  • 1,693
11 votes
3 answers
12k views

Bubble sort algorithm in Python

I'm starting to implement basic sorting algorithms. Criticisms on the implementation is welcome. ...
TravMatth's user avatar
  • 505
8 votes
1 answer
799 views

A fixed-size dynamic array

Background I implemented the historic std::dynarray according to the specification under the name dynamic_array in C++17. ...
L. F.'s user avatar
  • 9,508
3 votes
2 answers
1k views

Platform independant thread pool v2

This is a continuation of this question, v3 can be found here Taking into account the advise given by Loki, an implementation of the threadpool using a ...
Tom Myles's user avatar
  • 432
31 votes
1 answer
3k views

Yet another 'any' class implementation, named 'some'

This is a follow-up of 'any' class implementation. After posting my answer, I kept working on the code towards parameterizing with respect to memory management as I had promised. I ended up in some ...
iavr's user avatar
  • 2,274
24 votes
2 answers
15k views

Thread pool worker implementation

As an exercise in using C++11 features I decided to make a thread pool class. I would like to have a review on the code with focus on: Standards compliance / Portability issues / Best practices ...
Emily L.'s user avatar
  • 16.6k
16 votes
2 answers
3k views

ECDH implementation in python

I wrote an implementation of elliptic curve Diffie-Hellman key exchange in python. I would like to know if I could make it faster, cleaner or more secure: ...
Aemyl's user avatar
  • 690
15 votes
1 answer
4k views

Merge n sorted iterators

Over the weekend I was curious about efficiently merging multiple sorted iterators together, and for them to be in sorted order. This is quite like a challenge on HackerRank: You’re given the ...
Peilonrayz's user avatar
  • 43k
11 votes
5 answers
2k views

Portable Object-Oriented WC (Linux Utility word Count) C++ 20, Counts Lines, Words Bytes

This question Code lines counter prompted me to write my own line counting program. I program on both Windows and Linux and I know about the Linux utility wc. The command line and output format are ...
pacmaninbw's user avatar
  • 23.8k
10 votes
2 answers
6k views

Implementing nub (distinct)

I've implemented the following nub' or "give distinct elements of list" function: ...
Kevin Meredith's user avatar
8 votes
2 answers
428 views

Two dimensional gaussian image generator in C++

This is a follow-up question for Two dimensional bicubic interpolation implementation in C++ and Two dimensional gaussian image generator in C. Based on user673679's answer, another file ...
JimmyHu's user avatar
  • 4,370
7 votes
4 answers
364 views

IPv4 struct utilizing explicit layout

I was inspired by Processing a list to build an IP in String Format to reinvent the wheel a little bit and play around with explicit struct layouts. You see, an IP address is really made up of four,...
RubberDuck's user avatar
  • 30.8k
6 votes
1 answer
1k views

A standard-conforming C++17 std::optional implementation

I took quite some time to implement a fully standard-conforming std::optional in C++17. It turns out more sophisticated than I initially thought. My code is just ...
L. F.'s user avatar
  • 9,508
5 votes
1 answer
373 views

Simple spinlock for C using ASM

This is my second attempt to make simple lock using extended assembly. See https://stackoverflow.com/questions/37241553/locks-around-memory-manipulation-via-inline-assembly/37246263 The code: ...
user1235831's user avatar
5 votes
3 answers
3k views

Implement strtod parsing

In this comment the OP wrote, I am a newbie so i would like to know how would i parse the negetive numbers/arguments ? In this answer @200_success showed an implementation using the strtod ...
ChrisW's user avatar
  • 12.9k
5 votes
2 answers
158 views

Event emitter npm module

I was asked to complete the task described below: Event Emitters are objects that serve as the core building block in event-driven architectures. They simplify the process of handling asynchronous ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
5 votes
3 answers
958 views

Quicksort application

What do you think about this code? ...
user avatar
4 votes
2 answers
1k views

Serializing (nested) data structures in a human-readable format

I am reinventing the wheel to write a function that serializes a (nested) data structure human readably. The default output is deliberately similar to that of ...
Ξένη Γήινος's user avatar
4 votes
4 answers
1k views

Image Processing Median Filter in C

I am attempting to perform Median Filter with size 3 x 3 in C language. The function MedianFilter33 has been implemented as follows. The experimental implementation ...
JimmyHu's user avatar
  • 4,370
4 votes
3 answers
2k views

Two dimensional bicubic interpolation implementation in C

This is a follow-up question for Two dimensional bicubic interpolation implementation in Matlab and Two dimensional gaussian image generator in C. Besides the Matlab version code, I am attempting to ...
JimmyHu's user avatar
  • 4,370
4 votes
1 answer
2k views

Extendable PDO Wrapper Class

I've created a PDO wrapper. I understand PDO could be used on it's own, and I'm reinventing the wheel as there are solutions like Laravel's Eloquent that would do a better job. I'd like advice on ...
Alex Garrett's user avatar
3 votes
1 answer
80 views

Bar graph of Easter date distribution

Computing Easter for a given year is a classic computational problem. It is also one of the few cases when code seems to just have to live with magic numbers. Alternative to magic numbers: Decoding ...
chux - Reinstate Monica's user avatar
2 votes
1 answer
7k views

Return path between graph nodes using depth-first search

This code is meant to implement a Graph class which has a method that returns a path between 2 nodes using depth-first search. I'm doing this to improve my style ...
cycloidistic's user avatar
2 votes
2 answers
116 views

Serializing (nested) data structures in a human-readable format with all bugs fixed

See Serializing (nested) data structures in a human-readable format for more details. This is the latest version, I have fixed all bugs and now this piece of code works completely as intended. And I ...
Ξένη Γήινος's user avatar
2 votes
4 answers
3k views

Detect if a tree is complete binary tree

Detect if tree is complete binary tree. This question is improvement over previously asked here. Looking for code-review, optimizations and best practices. Verifying both space and time complexity to ...
JavaDeveloper's user avatar
2 votes
1 answer
145 views

Encryption/Decryption algorithm #2

This is a follow-up question to this one. I have tried to implement all the recommended things in the answers (except commenting, and not being OS specific). Again, if you see anything that needs ...
Have a nice day's user avatar
2 votes
1 answer
111 views

Pointer class/handle

Please review my pointer class. ...
lightning_missile's user avatar
2 votes
1 answer
280 views

Date validation in Java

I'm learning Java, and would really appreciate any tips on how to improve this code. It's just a simple date validation class. ...
Nilzone-'s user avatar
  • 1,416
2 votes
1 answer
187 views

Date validation in Java - take two

I read through and implemented the advice I received yesterday. I would, once again, really like some input on how this can be improved. e.g. encapsulation, interfaces, abstract classes etc.. Right ...
Nilzone-'s user avatar
  • 1,416
1 vote
2 answers
137 views

Neatly printing integers interspersed with spaces - follow-up

See the previous iteration. At this point, I have "digit group" length assumed to be always 3 the user can pass the delimiter character of his/her own handles (seems to handle) the minus sign ...
coderodde's user avatar
  • 27.6k
0 votes
2 answers
2k views

JSON string parsing

I need to parse a simple JSON string (flat JSON, no hierarchy) for keys and values, and there is a system constraint that I cannot use any built-in JSON library and can only read a string once due to ...
Lin Ma's user avatar
  • 3,443
0 votes
1 answer
268 views

Encryption/Decryption algorithm #3

This is a follow up question to Encryption/Decryption algorithm #2 and Encryption/Decryption algorithm. In my last question, in @Reinderien's answer, he added this line ...
Have a nice day's user avatar
25 votes
4 answers
98k views

Join List with Separator

I was implementing something similar to Python's join function, where join([a1, a2, ..., aN], separator :: String) returns ...
fabian789's user avatar
  • 353
22 votes
2 answers
4k views

Implementation of std::any

Today, I decided to implement std::any using the cppreference page. I've never actually used std::any before and after seeing ...
Indiana Kernick's user avatar
21 votes
2 answers
39k views

Generic DAO written in Java

I initially thought that this was just an architecture issue so I placed it on programmers as Thoughts on refactoring a generic DAO. Then I asked on codereview meta here and decided to put up the code ...
Aseem Bansal's user avatar
  • 2,259
17 votes
2 answers
361 views

YAVI (Yet another vector implementation)

I am a C# game developer currently learning C++. I am trying to implement some simplified STL containers. Here is my implementation of vector, which does not have the allocator (because ...
Marius T's user avatar
  • 381
15 votes
5 answers
22k views

Sine function in C / C++

Due to software constraints, I cannot use the standard libraries, cmath, algorithm, templates, inline, or boost. I am also using ...
Elpezmuerto's user avatar
14 votes
5 answers
27k views

Python Hash Table Implementation

I'm attempting to implement a basic hash table in Python using only lists. Any tips would be appreciated (including better hash functions). I intend this to handle collisions with separate chaining. ...
Brandon Deo's user avatar
14 votes
3 answers
2k views

Stack Implementation in C++ with Exceptions

Appreciate your thoughts and feedback... Stack.h ...
SRG's user avatar
  • 405
13 votes
4 answers
402 views

Bare-bones string library

After years of criticizing others, I've finally found the time and worked up the courage to polish up one of my bits of code and solicit criticisms of my own. This is a simple dynamic-string library ...
Corbin's user avatar
  • 10.6k
13 votes
1 answer
2k views

Implementation of std::deque (obsolete)

Warning: This implementation is obsolete, because it doesn't meet the standard. Specifically, while the standard guarantee any pointers and references to elements to remain valid after insertion or ...
Dannyu NDos's user avatar
13 votes
7 answers
26k views

C++ 3D Vector Implementation

I have been learning C++ now for 2 months and this week I started reading a book on 3D graphics. I like coding whatever mathematical stuff I learn so I can understand it better, so when I learnt about ...
user52988's user avatar
  • 133
12 votes
4 answers
8k views

strstr() implementation

In this strstr implementation, I am basically skipping the already matched and checked characters with an if else condition. Is ...
Software Engineer's user avatar
12 votes
3 answers
18k views

Implementation of C Standard Library Function ntohl()

This is an implementation of ntohl() that I wrote as an exercise. ntohl() takes a uint32_t ...
ex nihilo's user avatar
  • 699
12 votes
2 answers
3k views

Implementation of a generic List

I have only been self teaching myself programming on and off for about 5 months. The purpose of me writing this class is to incorporate the knowledge that I have gathered since I started. ...
Nate's user avatar
  • 253
12 votes
1 answer
2k views

Minimal C++ Unit Test Framework

I've written a minimal unit test framework. The goal was to allow assertions of booleans, for equality and catched exceptions. Two things are bugging the most. That assertions have to rely on macros ...
aggsol's user avatar
  • 404
11 votes
2 answers
1k views

Customised Java UTF-8

I have implemented a customized UTF-8 encoding mechanism. The code works fine, but I have a lot of concerns regarding the code. ...
srikanth's user avatar
  • 491
11 votes
2 answers
822 views

Smart but simple pointers

For practice, I've implemented my own smart pointer class. It's a 'unique pointer', meaning it doesn't allow copies of itself (when copying from a into ...
Aviv Cohn's user avatar
  • 321
11 votes
1 answer
334 views

C++17 pointer_traits implementation

pointer_traits is a lightweight trait that provides a uniform interface to builtin pointers and user-defined fancy pointers. That said, things like ...
L. F.'s user avatar
  • 9,508