Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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).

4
votes
3answers
300 views

LRU implementation in C++ using a LinkedList

Explanation : I am adding new elements in the list until the window runs out. Head will have the earliest element and tail will have the most recent element. Once the window is over, every addition ...
1
vote
2answers
51 views
6
votes
3answers
101 views

C++14 std::array implementation

I invested an hour or so to reimplement the C++ header <array>. Most stuff is in the namespace my_std, but ...
0
votes
2answers
65 views

Convert number to X base

As an educational exercise, I would like to make this code more efficient, with fewer lines, without using other standard functions. The goal here is to convert a number to X base and display it, (...
4
votes
0answers
77 views

Quicksort template (for sorting corresponding arrays)

I needed a function for sorting two corresponding arrays. So I wrote this code to sort N corresponding arrays! The really "metaprogrammy" way to do it would be to use ...
9
votes
1answer
441 views

Simple LinkedList

I guess this has been made a couple of times by now, but i wanted to take my chance on creating a simple generic linked list in c#. What do you think ? This is the main class. ...
6
votes
1answer
94 views

unique_ptr basic implementation for single objects

This is an implementation to simulate the basic functionality of unique_ptr. This doesn't provide features like custom deleter and ...
5
votes
2answers
97 views

C++ Maybe<T> implementation

In order to improve my understanding of C++ template meta-programming, SFINAE, references, and overall class design, I've tried to implement a Maybe<T> class ...
2
votes
1answer
50 views

Python implementation of Conway's chained arrow notation

A year ago, I implemented an evaluation algorithm for Conway's chained arrow notation in Python. I'd like to get a review on my code, especially about readability and if it is pythonic. I'd also like ...
9
votes
3answers
643 views

Simple re-implementation of std::vector

Here is a simple reimplementation of most of std::vector. I want to check if I implement it correctly but the standard libraries source code is not very readable ...
3
votes
0answers
81 views

C++ program that processes unique markup language similar to HTML

I have solved a task which takes input in a unique markup language. In this language each element consists of a starting and closing tag. Only starting tags can have attributes. Each attribute has a ...
4
votes
1answer
142 views

Sorting an array in C++

This started as a simple exercise in sorting an array. I wanted to make it a bit more complex which is why I made it a 2D array. I then noticed that each pass that checked and swapped values, it was ...
5
votes
8answers
313 views

List implementation in C

I tried to implement a Python-esque list in C. Having not really used C in anger, I'd like some pointers on style and error handling in particular. Header ...
2
votes
1answer
67 views

C++ template-based dimension-tagged type

I'm writing a small C++14 library for myself that allows me to decorate a type with dimensionality information, so that I can leverage the template/type system to avoid mistakes such as adding ...
4
votes
3answers
103 views

strlen and strcmp implementation in x86 FASM assembly

I wrote my own implementation of strlen and strcmp from C in x86 FASM and I would like to know is there anything that should be changed or improved. strlen needs string in eax and is returning length ...
6
votes
2answers
133 views

RSA c implementation

This is my first attempt to implement a crypto algorithm. I am using C and gmp to interact with big numbers. Here is my code; you can run it after having linked with the ...
1
vote
0answers
23 views

Custom Vector and Matrix classes in python for machine learning

I am creating a machine learning tool set from scratch in python. I have never done something of this kind and I don't usually use python but I thought it would be good to expand my horizons. I am ...
1
vote
1answer
61 views

Quicksort in C with unit testing framework

This is my quicksort There are many like it but This quicksort is mine. So, quicksort, in C, with a big framework to test it six ways from Sunday. Passed the tests nicely, but there may be warts, or ...
3
votes
2answers
99 views

Verify a subnet mask for validity in Python

I've written a small Python function to check whether a string is a valid IPv4 subnet mask. It works but maybe it's too convoluted and terse? Or maybe it could be improved / optimised / rewritten in ...
0
votes
1answer
79 views

Implementation of a Hash Map in C++

I created a templated Hash Map class in C++, which supports most of the basic C++ types (e.g. int, float, ...
3
votes
2answers
268 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. ...
5
votes
3answers
125 views

Singly-linked list data structure implementation

This code seems to work correctly. I would appreciate any comments on how to improve the code, e.g. readability, algorithms, const-correctness, memory, anything else I am forgetting? Also, for the ...
3
votes
2answers
66 views

Singly linked list class

I have created this program about using a singly linked list class that implements several functions: Add, Display and ...
3
votes
2answers
99 views

Remove value from linked list if it is equal to a parameter

Problem: Given a singly linked list of integers l and an integer k, remove all elements from list l that have a value equal to k. My solution works, but I suspect it's not smart and optimized ...
3
votes
3answers
79 views

Pseudo-truly random number generator

I am creating what strives to be a truly random number generator. As of right now, the implementation uses a mix of mainly nonsense system data and some pseudo-random numbers to generate numbers that ...
1
vote
2answers
92 views

HashMap implementation, is this good enough for interviews?

After understanding HashMaps, I decided to implement my own using 3 classes HashMap, LinkedList, and Node. I knew how to implement LinkedList from before. Can you please give me feedback on this. ...
5
votes
1answer
142 views

Maximum Heap Container

I implemented this max-heap to satisfy the C++ Container requirements. I am fairly confident I implemented bubble_up, bubble_down...
1
vote
3answers
121 views

Generate all possible permutations of a string in C++

This is my version of the possible permutations of a string challenge. Please give me feedback or criticism. There are two vectors here: positions and ...
5
votes
3answers
224 views

Picking the smallest value in a list using recursion

This is the code I wrote in order to find the smallest value in a list using recursion.However I feel like there would be a better way to do this? ...
2
votes
1answer
49 views

Implementing foldl1 in Haskell

As an exercise (scroll to the first set of exercises) for learning Haskell, I have to implement foldl1. I believe I have implemented it successfully and while ...
8
votes
2answers
241 views

std::array implementation

I'm creating my own implementation of the STL, compliant with the C++17 standard. The only purposeful differences are that the namespace is hsl (homebrew standard ...
2
votes
4answers
170 views

Split a string into a list of tokens

I have the following assignment that I succeeded in solving, but the code is very inefficient. I would appreciate if someone could show me a more efficient way, perhaps with substring. Note that I am ...
6
votes
0answers
56 views

Minimal regex engine

A few months back, I posted a state machine for review. Thanks to the feedback, I was able to greatly simplify the implementation. I am posting the revised version, together with the Regex class which ...
4
votes
4answers
107 views

A queue implemented using an array

We've just finished learning about queues in my data structures class; I want to make sure I really understand it. I'm still feeling a bit lost on how to optimize the data use of a queue. I've ...
2
votes
1answer
62 views

Pythonic quick sort

I'm new to the world of python, and wrote this quick sort implementation which was taught to us in an algorithms class. I would like to learn to write code less like C++ and more pythonic. Could you ...
1
vote
1answer
210 views

Multithreaded non-blocking tiny echo server

I wrote this code to make a non-blocking server without using select(), my main concern is to catch as many exceptions as possible for worst case scenarios (so I ...
5
votes
2answers
156 views

String to binary converter

I did research about binary counting, and wanted to make an application in Java that converts a string to binary code: ...
2
votes
3answers
183 views

Addition of 2 integers

I've implemented an algorithm found in a book. It adds 2 positive integers of equal size. How can it be improved? It is assumed that inputted data is always positive integers with an equal number of ...
3
votes
0answers
26 views

Use a pattern for fields validation

I need to validate the fields of user sent by an API. All works fine but the only one problem is that I don't like the solution is not an OOP solution. In the controller I call the service created by ...
4
votes
2answers
364 views

C++ linked list inheritance hierarchy

I'm about to post quite a bit of code. Hopefully, someone is willing to put some time into reviewing it all. I know linked lists have been done a lot on here, but I wanted to improve the basic C++ ...
2
votes
1answer
41 views

Haskell 'n' layered ANN forward pass

I'm trying to write a simple 'n' layered ANN in haskell for supervised learning, it will eventually have back prop and you'll be able to use it in a step by step fashion through a GUI which will graph ...
10
votes
3answers
412 views

Implementation of Linux cp in modern C++

This is my simple implementation of the Unix cp command. It is a C++ program but makes use of some of the lower level C library I/O functions. Any suggestions for ...
7
votes
3answers
986 views

Sorting three ways

I have implemented function templates that take a begin and end iterator as well as an optional comparator for user-defined types. It was my intention to mimic the usage of ...
6
votes
5answers
913 views

Dynamic fgets in C

I wanted to make a function that will dynamically retrieve a line from a stream to a buffer. This function just needs to take in the char* and the stream to read ...
0
votes
1answer
29 views

Throttle redraw requests fired from pointer events

I am working on a photo editor, which displays a preview to the user on a canvas. At various points in the app, the user may use sliders to adjust properties of the photo, such as scaling, rotation, ...
5
votes
2answers
94 views

Move friendly merge sort - follow-up

This is a follow up to this question. I'm only interested to see if this is implemented correctly for move-only types. ...
6
votes
1answer
81 views

Library for RCON clients

I wrote a library implementing the RCON protocol to automate interaction with Minecraft servers. I know that there are already a couple of implementations out there, but neither I found was convincing ...
9
votes
2answers
283 views

Modern C++ singly linked list

This is a rather minimal (though fully functional) implementation of a singly linked list. It supports \$\mathcal{O}(1)\$ front insertion and deletions, as well as \$\mathcal{O}(1)\$ random insertions ...
5
votes
2answers
75 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 ...
2
votes
0answers
82 views

Drawing an ASCII grid in Ruby based on a 2D array

I'm writing a function that renders a grid using ASCII line-drawing characters, based on a provided 2D array (or array of arrays), with each top-level array representing a row, and the items inside ...