Yet another implementation of the immutable data structures in Okasaki's textbook, "Purely Functional Data Structures", in C++.
A C++20 compatible compiler is necessary. For instance, g++ 10.2.0 with -std=c++20
flag compiles the codes successfully.
-
The code is at a very early stage. There should be bugs and rough edges.
-
In Chapter 10 and 11, we need a polymorphic recursion. Although the static typing system of C++ forbids a proliferation of infinite number of types at compile time (i.e., a genuine polymorphic recursion), we can introduce the auxiliary cutoff for the number of the recursions with constexpr-if; If the depth of the recursion exceeds this cutoff number, the runtime exception is thrown. I will use this pseudo "polymorphic recursion".
- Leftist Heap
- Weight Biased Leftist Heap
- Binomial Heap
- Explicit Minimum Binomial Heap
- Red Black Tree
- Red Black Tree with not-so-efficient-delete
- Queue
- Deque
- Splay Heap
- Pairing Heap
- Alt Binary Random Access List
- Bootstrapped Queue
- Catenable List
- Trie
- Hash Table
- Trie of Trees
okasaki: Purely Functional Data Structures
type erasure: C++ Templates - The Complete Guide
lazy evaluation: Functional Programming in C++