Klib
STC
Our great sponsors
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Klib
- C++ containers but in C
-
Im looking for a good hashtable fonction to use
If you want a generic, extremely high performance implementation. I really recommend khash: https://github.com/attractivechaos/klib/blob/master/khashl.h
- What if Linus Torvalds used C++ instead of C
-
sqzlib - kseq compatible DNA fastA/Q encoding and compression library
Most importantly, sqzlib is fully compatible with klib/kseq.h one of the highest performance fastA/Q parsers. This means that any application that uses kseq.h for fastA/Q parsing, can be easily modified to use sqzlib instead. You can find patched versions of seqstats, minimap2, and bwa-mem2 in my github, or you can patch them yourself with the included patches.
-
"Implementing Hash Tables in C" (an article I've drafter a few years ago, but never published it until... now)
I don;t know if you are aware of khash? It's a very nifty hash table implementation. It is one of the fastest hash table implementations out there. Heavily used in bioinformatics. You said in your post that you are a macro guy, well, you are in for a treat with this library.
- Metaprogramming custom control structures in C
- I still like C and strongly dislike C++
-
Type-safe generic data structures in C
This is in fact a pretty common pattern in production code.
Here's an entire suit of type safe generic data structures in C: https://github.com/attractivechaos/klib
-
How to structure C code? It appears to reward shallow functions and doing everything in the global scope, whereas other languages let you go as deep as you want at no cost.
You will probably want to invest some time into either finding a good data structures library (preferable) or writing your own data structures (fine to do but not a good use of your time if you're starting out). You can try SGLIB or klib.
- Performance comparison: counting words in Python, Go, C++, C, AWK, Forth, and Rust
STC
- How would I go about implementing a C++ map or unordered_map in pure C?
-
Containers Library in C
u/attractivechaos: I relate this to my own STC container library, which is a "true" templated library. When specifying a raw pointer as value type for the hashmap, and no value destructor, it behaves like a non-owning container. The user therefore manage the pointed-to data elements (or "nodes"), and can apply the "trick" you mention, so there is no memory size advantage for the intrusive map over a hashmap in this regard.
- Modern programming languages require generics
-
How different is C++ from C? Contrasting simple Unix SORT programs
But the most common that I know of is this one: https://github.com/tylov/STC. There's also this one mentioned above https://rurban.github.io/ctl/
To illustrate, using a generic typesafe container lib, like my own STC, it is just as simple to write this in C. Also uses RAII (c_auto macro). cvec is templated, here using the lib's string type, so cvec_str is already pre-configured, but containers can use any custom elements type-safely:
-
Upgrading my PRNG for procedural generation
sfc64 is about the same speed as sfc32, so almost twice as fast per bit generated on most 64-bit platforms. I have a slightly modified version in my STC library which is equally fast, but supports threads/streams, similar to PCG. The lack of streams or jump function is one of the few criticisms to sfc. In my mind it is merely a theoretical limitation, as the chance for repeating subsequence are incredible small, but if you need that assurance, my variant can be interesting as it is quite a bit faster than e.g. xoshiro and not sensitive to "bad" seeds.
-
Are you using Boost intrusive containers?
The background for the question is that many C programmers swears to use intrusive containers as the superior alternative to STL-style containers. I have a templated C container library in STL style (compiles in C++, works with standard layout types only), and have argued that for most cases, traditional STL-style containers are more natural and easier to manage. But I believe there are situations where intrusive containers are better.
-
Generic C Library
I didn't intend to mention my own templated STC container library, but I am confident that it is superior to any intrusive or other generic container C libraries for that matter. That's a bold statement, but I'll be happy to compare anything from usability (API), memory usage, speed or library footprint with any other container lib, intrusive or not.
-
"double free or corruption (out)" what is causing this to happen here?
FYI. You can write this portable, more robustly with my STC library with less lines, but it takes some effort to understand the workings of a library too. Note that the non-portable POSIX getline() includes the newline char in the line (seldom desirable). cstr_getline() does not. c_autovar is an optional convenience macro, you can use ..init() and then ..drop() at end of function instead.
-
Help in starting
Just remember, if you choose C and you need to use the basic containers that C++ includes in its standard library like vectors and maps, use this library, it will make your life so much easier!
What are some alternatives?
ZLib - A massively spiffy yet delicately unobtrusive compression library.
ZXing - ZXing ("Zebra Crossing") barcode scanning library for Java, Android
Better Enums - C++ compile-time enum to string, iteration, in a single header file
ctl - My variant of the C Template Library
libevent - Event notification library
Geany - A fast and lightweight IDE
ctl - The C Template Library
HTTP Parser - http request/response parser for c
megahash - A super-fast C++ hash table with Node.js wrapper, tested up to 1 billion keys.
Cppcheck - static analysis of C/C++ code
quadsort - Quadsort is a stable adaptive merge sort which is faster than quicksort.
C++ Format - A modern formatting library