Skip to content
cvikupitz edited this page Dec 26, 2020 · 6 revisions

The libcds library contains a collection of generic data structures one would typically use when developing a (somewhat) complex project. In many modern languages, a utility library usually comes with the language that conveniently offers just enough (or more) functionality to get the job done. In Java, we have the java.util package and all its classes. In Python, we have some of the built-in structures such as lists and dictionaries. In C++, we have the STL library. In C, however, no such library exists, and programmers are usually required to implement their own versions in order to achieve what they want. This library aims to provide a similar collection of data structures, and aims to mock the APIs and functionality from the data structures from the Java 7 utility package.

As of now, the main limitation behind the generic data structures is that C does not support generics the same way as Java. This means that the users are responsible for maintaining the typing in the containers they use. All items that are inserted should be cast to a void * and should then be cast back to the original type after retrievals. Better support for this may be looked at in future patch work.

The library currently contains implementations of the following structures, one version that is not thread-safe, and another that is thread-safe:

  • Stack (Bounded & Unbounded)
  • Queue (Bounded & Unbounded)
  • ArrayList
  • LinkedList
  • Circular List
  • Minimum Heap
  • HashMap
  • HashSet
  • TreeMap
  • TreeSet