My junk code repository has some small projects and several code examples in C, C++, C#, Python, Bash and AWK.
The most interesting ones are listed below and the repository information is at the end of this page.
Some time ago I have tried to port the USB Serial layer to use the Serial Core subsystem but it showed some problems with the fact that USB devices have to sleep when changing device settings... Anyway, the original pachset is here and I have written two drivers to understand how the Serial Core and TTY subsystems work, code is here.
Besides that the linux-kernel directory has examples of debugfs, netlink, rbtree and others.
There are examples of lists (singly-linked, doubly-linked and circulary-linked), queue, stack, hash-tables and binary-tree.
I have written a program to search for an address in Curitiba given the CEP number (Brazil's post code system). The program can use the following data structures to store the addresses information:The user can choose the data structure in the command-line. There is also a version in Python and C# with different data structures.
- Singly-linked list
- Binary search tree
- AVL tree
- AA tree
Sometimes, when you are writting a program or library, you need to use something better than an array to store data but you do not want to use dynamic memory or anything complicated.
The solution is to use the "static version" of some known data structure.
Mega-Sena is the name of Brazil's most valuable national loterry. I have written a program which reads all the Mega-Sena results in memory (they are available in the Web) and does the loterry.
The program uses a hash table to store its data, and the user can choose the following types of hash-tables:
- Open Addressing (linear probing)
- Cuckoo hashing