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
38 votes
6 answers
21k views

Random IP Address Generator

randip.py I know there are probably better, easier ways to do this. It was just a bit of a learning exercise for the sake of familiarising myself with Python. It takes a single argument (positional ...
user avatar
  • 729
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 ...
user avatar
  • 2,276
28 votes
5 answers
7k views

C++ logging library

I am creating a logging library in C++, and I wanted your opinion on code quality and performance within some methods. You may ask why yet another logger - the answer is simple. This logging library ...
user avatar
28 votes
5 answers
5k views

C++ Vector Clone

I'm learning C++, so I decided to make a simpler clone of std::vector. Concerns: I have seen people defining methods outside of the class, and only prototyping ...
user avatar
27 votes
7 answers
8k views

Python program to calculate GCD

...
user avatar
25 votes
5 answers
18k views

Implementing realloc in C

I have an assignment to implement realloc in C, This's my code please review it. ...
user avatar
25 votes
6 answers
6k views

C++ string operators

I'm trying to practice my C++ on my own; At the moment I'm trying to implement the concept of operator overloading making my own string class/function. I think I handled this correctly; the code ...
user avatar
25 votes
4 answers
92k views

Join List with Separator

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

IEEE 754 square root with Newton-Raphson

I have an implementation of the sqrt function that uses a combination of IEEE 754, packed bitfields, and the Newton-Raphson algorithm: ...
user avatar
  • 1,714
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 ...
user avatar
  • 16.4k
23 votes
6 answers
5k views

Implementing any_of in C++

I've decided to implement Python's any in C++. I've gone about this using templates to allow multiple types of data to be passed, instead of overloading the ...
user avatar
  • 9,587
23 votes
8 answers
6k views

Optimize custom double.parse()

In my company's code, they use double.tryParse() which is quite good but sets too much security for our needs. As we sometimes have to parse a few billion strings, ...
user avatar
22 votes
5 answers
11k views

Linked List in C#

I was searching for a implementation of a Linked List with the same power as a native List. I wanted functionality closer to a ...
user avatar
  • 365
22 votes
3 answers
3k views

Look 'ma, I can read code

I have put together a naive implementation of a VB6/VBA parser, and I'd like to see if the CR community sees the same things as I see can be improved with this code, before I start refactoring. I've ...
user avatar
21 votes
4 answers
84k views

STL vector implementation

I've implemented a simple vector-like structure. I would appreciate all criticism relevant to code, style, flow, camelCase vs underscore, and so forth. ...
user avatar
21 votes
2 answers
38k 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 ...
user avatar
  • 2,269
19 votes
2 answers
2k 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 ...
user avatar
17 votes
2 answers
332 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 ...
user avatar
  • 381
17 votes
1 answer
18k views

Min/Max Heap implementation in Python

I'm refreshing some of my datastructures. I saw this as the perfect opportunity to get some feedback on my code. I'm interested in: Algorithm wise: Is my implementation correct? (The tests say so) ...
user avatar
  • 1,440
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 ...
user avatar
  • 96.7k
17 votes
2 answers
508 views

Re-implementation of `std::tuple` for MCUs

Background I'm writing code for an 8-bit MCU with very limited RAM (1KiB) and program flash space (64KiB). I have a C++14 capable compiler with no standard library implementation available. This is a ...
user avatar
  • 16.4k
16 votes
6 answers
2k views

A file class for Python

This is the entire code segment. All the functions for file operations are working perfectly. I just need a professional to help me clarify that am following good standards, documentation, etc., ...
user avatar
16 votes
4 answers
2k views

String Queue implementation

Is the implementation clean enough & can be used in production? I tried to write clean & bug-free code. It looks good to me. I would appreciate any improvement suggestions. One question I ...
user avatar
  • 163
16 votes
7 answers
13k views

Hexadecimal to integer conversion function

I am working through Kernighan and Ritchie to brush up on my C skills, so I thought I would invite critiques of my code. Here is my Hex-to-int function: ...
user avatar
16 votes
3 answers
770 views

Super calculator in C

For my mathematical research, I am to deal with very large numbers and I know that the standard C types are not going to stand a chance against them due to their limited capacity, so I decided to ...
user avatar
  • 469
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: ...
user avatar
  • 690
16 votes
1 answer
24k views

Self-contained SHA-256 implementation in C

I have been looking for a SHA-256 implementation in C with no dependencies (preferably self-contained in a single C-file) with a permissive license but found none to my liking. Since the Wikipedia ...
user avatar
  • 497
15 votes
7 answers
8k views

Why does caching of string objects perform faster?

I'm trying to implement String-Pool. I'm maintaining a HashMap<String,String> to store the keys. ...
user avatar
  • 461
15 votes
5 answers
21k 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 ...
user avatar
15 votes
1 answer
3k 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 ...
user avatar
  • 41.7k
15 votes
1 answer
1k views

std::string implementation attempt

The following is my attempt at a string class that behaves like std::string. Any feedback would be appreciated. my_string.h ...
user avatar
14 votes
4 answers
2k views

Using Python enums to define physical units

I'm using Python's Enum to define the physical units in which a value is expressed. Eventually, I want to add them as an attribute to my ...
user avatar
  • 261
14 votes
3 answers
2k views

Stack Implementation in C++ with Exceptions

Appreciate your thoughts and feedback... Stack.h ...
user avatar
  • 405
14 votes
3 answers
5k views

Reimplementing Python's enum.auto() for compatibility

In Python >= 3.6 there is an enum.auto() function. The auto() function can be used like this: ...
user avatar
  • 315
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. ...
user avatar
14 votes
1 answer
7k views

Graph implementation adjacency list 2.0

Version 1: Graph implementation adjacency list 1.0 Please note the following: All edges are directed A user of the class Graph shall never be able to aces an object of type ...
user avatar
  • 437
13 votes
6 answers
7k views

Modern Vector implementation

Please give me some feedback on my attempt at a vector. I wanted this to be the lowest level concept of a vector that I'm using, so I'm primarily concerned with speed, and I would build wrappers ...
user avatar
13 votes
5 answers
3k views

Stack class in Java 8

I have a exercise where I have to write a Stack class with the push and pop methods. The code compiles and works as it should. Are there better practices to use in my code? Is there something I should ...
user avatar
  • 231
13 votes
7 answers
25k 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 ...
user avatar
  • 133
13 votes
3 answers
24k views

Min / Max function of 1D array in C / C++

Due to software constraints, I cannot use the standard libraries, <math.h>, <algorithm>, templates, ...
user avatar
13 votes
3 answers
11k views

Python implementation of SHA1

Here is a implementation of the cryptographic hash function SHA1 written in Python. It does not use any external libraries, only built-in functions. I know that it would be faster to use an external ...
user avatar
  • 1,517
13 votes
2 answers
28k views

Ring Buffer Implementation in C++14

A ring buffer or circular buffer is a fixed sized queue that advances head and tail pointers in a modulo manner rather than moving the data. Ring buffers are often used in embedded computer design. ...
user avatar
  • 447
13 votes
4 answers
374 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 ...
user avatar
  • 10.5k
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 ...
user avatar
13 votes
1 answer
1k views

Pure python range implementation

I implemented class Range as an equivalent to Python built-in range for practicing purposes. No features were added. Hope it ...
user avatar
  • 285
13 votes
1 answer
245 views

Logging library

Due to several limitations of the standard library's logging module, I wrote my own. Below are the most important parts. You can find the whole library here. Any feedback is welcome. ...
user avatar
12 votes
3 answers
12k views

STL queue implementation

I've implemented a simple C++ STL like queue. (I've tried to follow @LokiAstari stack implementation code fashion) ...
user avatar
12 votes
3 answers
14k 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 ...
user avatar
  • 699
12 votes
2 answers
3k views

Implementation of memmove

Here is my implementation of memmove; where can I improve? ...
user avatar
  • 475
12 votes
3 answers
14k views

Simple C# HashTable Implementation

Haven't put one of these together since college. How does this look overall? ...
user avatar

1
2 3 4 5
19