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
6
votes
3answers
4k views

Implementing Transpose

I'm implementing transpose in Haskell. -- transpose [[1,2,3],[4,5,6],[7,8,9]] -- [[1,4,7],[2,5,8],[3,6,9]] Please give it a ...
29
votes
1answer
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 ...
4
votes
2answers
768 views

Writing Data.List's intersperse

Learn You a Haskell shows the intersperse function: ...
3
votes
1answer
356 views
7
votes
2answers
3k views

Implementing nub (distinct)

I've implemented the following nub' or "give distinct elements of list" function: ...
10
votes
2answers
6k views

'any' class implementation

I have made an any class in C++, base loosely on boost::any, but written differently. I am checking to see if I have done it ...
15
votes
7answers
7k 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. ...
6
votes
2answers
865 views

Clone of an undirected graph

Perform a graph clone. Verifying complexity to be O(E). Looking for code review, optimizations and best practices. ...
11
votes
3answers
13k views

LinkedList implementation implementing the List interface in Java

So here it is, my linked-list implementation in Java. I have coded against Java's List<E> interface as if my ...
6
votes
2answers
10k views

Singly linked list implementation

I feel like there is room for improvement in the push/pop methods. Any suggestions? ...
12
votes
5answers
15k views

Implementation of atoi()

I implemented the atoi() function! Here is my code: ...
4
votes
2answers
2k views

Power function in JavaScript

I know that there may be better ways of writing this do you think that this code is written well enough to be used in a real world application? ...
5
votes
1answer
2k views

jQuery Load More Plugin

This is a simple load more plugin, built for teaching purposes. For this reason, it's not pretty in terms of output. I'd like to know if this can be improved, or if anyone can spot any major problems ...
5
votes
3answers
2k 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 ...
4
votes
1answer
638 views

Raw JS AJAX method

I built this as a simple example of using raw JS to perform a simple GET request with a data callback. Suggestions on how this could be improved in any way, while keeping it simple, would be much ...
3
votes
1answer
330 views

Small animation with Raphael

I have a small animation with Raphael using a large amount of code. Is there any way to reduce it? Demo ...
7
votes
2answers
489 views

Can this recursive binary search in C be made more concise?

Can someone please let me know if they see glaring issues with this code? I tested a handful of cases and it seems to work but in other threads. I often see much more concisely written versions of ...
3
votes
3answers
17k views

Implementation of std::map

I have decided to make a basic C++ implementation of the std::map class, and I was checking that it is fine, as I am not sure if the ...
5
votes
1answer
169 views

Am I including these JavaScript files correctly?

I just want to know if this is reasonably good implementation of including local/remote JavaScript files. The function takes a dictionary with (string) .src ...
5
votes
1answer
3k views

Regex parser implementing dot, star and question mark

Regex parser which follows the following rule . (dot) means a any single character match * (star) means 0 or more ...
1
vote
2answers
796 views

Smart pointer implementation

I've decided to implement a simple smart pointer: ...
1
vote
1answer
3k views

std::function implementation

I've decided to make an implementation of the C++11 class function. I was checking that I have done everything correctly and have not missed anything: ...
7
votes
3answers
14k views

Binary string to integer and integer to binary string

I am working through K&R for review and I thought that I would write some of my own routines for conversion of binary strings to int and int to binary string. I realize this is reinvetning the ...
4
votes
2answers
645 views

Reimplementation of C++ vector

I previously attempted to make a C++ vector here, yet it was not very successful. Now I have made a basic reimplementation of it, so I'm checking that it is fine, and that I will not have to re make ...
14
votes
7answers
12k 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: ...
10
votes
2answers
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. ...
5
votes
2answers
324 views

Basic C++ object class

I have implemented a basic object class in C++, and I want to make sure that I have implemented everything efficiently and safely, as I made a few mistakes while ...
4
votes
1answer
1k views

basic_string implementation

I have attempted to make a basic version [not complete] of the std::basic_string type in C++, and I would like to make sure that I have done everything correctly, ...
10
votes
3answers
3k views

Is decimal, hexadecimal, octadecimal, binary converter efficient?

I have made a method which takes two parameters: the value to convert and the base. Based upon those two parameters my method is adjusted (with several helper methods) to change the desired decimal ...
5
votes
1answer
837 views

Lock-free producer/consumer implementation

I know of BlockingCollection in .net, but this is rather for my understanding of the pattern. Is this implementation correct ? Consumer ...
7
votes
2answers
17k views

Find whether a given number is a perfect square or not

I am trying to find whether a given number is a perfect square or not by using just addition and subtraction. Please review my code. ...
6
votes
1answer
12k views

memcpy() implementation

I have tried to write a function like memcpy. It copies sizeof(long) bytes at a time. What surprised me is how inefficient it ...
11
votes
3answers
12k views

Bubble sort algorithm in Python

I'm starting to implement basic sorting algorithms. Criticisms on the implementation is welcome. ...
5
votes
2answers
5k views

AES CTR mode using pycrypto

I've implemented CTR mode by myself (only decryption for now), using only AES built-in functions from pycrypto. It means that I'm not supposed to use mode=AES.MODE_CTR. However, I know that using AES....
2
votes
1answer
73 views

A class for dynamic inputs

This class creates dynamic input labels. You give it a pair of elements and it sets up the event listeners and CSS toggles to accomplish this. Looking for feedback on code structure and correctness. ...
3
votes
2answers
2k views

Find power of a number

Looking for optimization, smart tips and verification of complexity: O (log (base 2) power). NOTE: System.out.println("Expected 16, Actual: " + Power.pow(2, 7)); ...
5
votes
5answers
15k views

Finding index of first substring

I wrote this function to find the index of the first substring. I was wondering if you can help me find some flaws or possibly help increase performance? Example: str = "happy" substr = "app" ...
3
votes
1answer
261 views

Removing a link from a linked list

I have written a method for removing a link from a linked list for a phonebook project I'm currently working on and it works perfectly. However, I want to know whether or not my code is acceptable ...
11
votes
3answers
7k 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 ...
19
votes
2answers
36k 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 ...
8
votes
3answers
20k views

Binary search for inserting in array

I have written a method that uses binary search to insert a value into an array. It is working, but i would like to get a second opinion to see if i didn't write too much code for it. aka doing same ...
11
votes
1answer
409 views

C++ linq-like library

I want to implement something like C# Linq in C++ Currently only select and where is implemented, but others should be fairly ...
5
votes
1answer
753 views

Regex parser - request for review and optimization

The whole question is Simplified regular expression engine. I have solved the question, and in turn felt the need to get it reviewed. Any suggestions for clean up and optimization would help. Also ...
3
votes
1answer
3k views

Function equivalent to strcmp()

I'm starting out and need feedback in order to discover the things I'm doing wrong. This is supposed to behave like strcmp(): ...
7
votes
3answers
27k views

Day counter between two dates

I wrote this little program, but I'm not sure if it's properly written. Actually, it can't handle leap years (every year is 365 days long) and you have to write the earlier date before. It seems to ...
4
votes
1answer
411 views

Yet another shared pointer

What might be wrong with this shared pointer? One good point of it might be, that it should handle array types correctly by default (e.g. ...
6
votes
2answers
15k views

Template vector class

I am trying to implement a vector-like container of my own (just to gain a better understanding of how std::vector works under the hood). I've been using this as a ...
7
votes
3answers
329 views

Mimicking the basic interface of std::stack

I am trying to mimic std::stack in my implementation (just the basic interface - no iterators / allocators). Since I was having trouble handling all the memory ...
5
votes
2answers
2k views

Reading and parsing CSV files

This is my first real attempt at a Scala program. I come from a predominantly Java background, so I'd like to know if the program sticks to Scala conventions well. Is it well readable or should it ...
5
votes
2answers
5k views

HMAC-SHA1 implementation

I am trying out a small piece of code that would generate HMAC-SHA1. I have been asked to code the HMAC implementation myself using the OpenSSL libs for SHA1 calculation. After 'wiki'ing for the ...