9 Reusable Code Snippet Topics

Remove Filter
Member Avatar for Narue
Member Avatar for Narue

This is an example of using a binary index file to speed up random access of lines in a file. The file is indexed one time, where the position of the start of each line is stored in an index file. Subsequent requests for a get the position from the …

4
366
Member Avatar for Narue

In answer to a coworker's question today about memory management today, I wrote the following code. It's an implementation of the gets function that accepts an infinite length string (bounded only by the heap) and [i]does not[/i] force the caller to free the resulting pointer. I figure that it's a …

Member Avatar for Narue
3
378
Member Avatar for Narue

FASM can output an executable PE directly, but sometimes you want to output an object file for linking with modules in other languages. The following program can be used to link with the C library of the GCC compiler with the following commands: C:\>fasm hello.asm hello.obj C:\>gcc hello.obj -o hello.exe …

0
279
Member Avatar for Narue

Some languages are hard to get started in. FASM appears to be one of these languages because the documentation is not detailed enough for a beginner. That's a shame because FASM is (in my opinion) one of the better assemblers. The following snippet is a simple Hello, world! program which …

0
1K
Member Avatar for Narue

A fairly complete implementation to provide another perspective on a seemingly simple program.

Member Avatar for Ene Uran
0
146
Member Avatar for Narue

This code demonstrates AVL insertion and deletion. The code was originally written in C by myself a little while back for a tutorial. The translation to Java was fairly trivial, and to add a little excitement I even threw in a few generics. Yes, I'm aware of this line: tree.data …

Member Avatar for easternRAT
2
342
Member Avatar for Narue

Insertion sort, Selection sort, Bubble sort, Shell sort, Quicksort, and Heapsot. All optimized and ready to be experimented with. This is the framework for a Java application that speed tests various sorting algorithms (because there's usually little need to write one's own in production programs). Several popular algorithms were left …

Member Avatar for majestic0110
1
361
Member Avatar for Narue

This quicksort implements the basic recursive algorithm with three improvements. The first improvement is choosing the pivot based on the median of three values in the list to be sorted. This minimizes the chances of a worst case scenario. The second improvement speeds up the algorithm by termination when subfiles …

Member Avatar for Matt Labbé
1
1K

The End.