Skip to content
Eugene Lazutkin edited this page Jun 11, 2024 · 10 revisions

list-toolkit

After implementing list-based structures countless times, I finally decided to write them down as an open source project.

The toolkit deals with lists, related data structures and their practical applications.

Concepts

A list is a simple yet versatile data structure with a lot of possible design decisions. I suggest to skim over the wiki in the following order:

DLL: double linked lists

A doubly linked list is the most flexible data structure. The API is described in the following documents:

  • Foundation — the foundational classes and methods of the implementation.
  • Lists — the hosted list classes and methods.
  • Pointers — the pointers API for doubly-linked lists.
  • External lists — the external headless lists API.

SLL: singly linked lists

A singly linked list is the minimalist data structure yet the most performant. The API is described in the following documents:

  • Foundation — the foundational classes and methods of the implementation.
  • Lists — the hosted list classes and methods.
  • Pointers — the pointers API for singly-linked lists.
  • External lists — the external headless lists API.

List utilities

The toolkit provides the following list utilities:

Caches

Caches are data structures based on lists. The toolkit provides the following caches:

  • CacheLRU — a least recently used (LRU) cache.
  • CacheFIFO — a first in, first out (FIFO) cache.
  • CacheLFU — a least frequently used (LFU) cache.
  • CacheRandom — a cache with randomly removed items.

All caches have the same API but may have different options. The API is described in this document: Caches.

Additionally it provides a decorator to cache results of a function/method call based on the first argument: Cache decorator.

If you want a more complex caching schema for your functions you can easily create more complex decorator.

Heaps

Heaps are data structures used to track min/max elements efficiently. The toolkit provides the following heaps:

Strictly speaking heaps are tree-like data structures, which are not usually based on lists. But they are frequently used together, so we decided to provide them as well.

Queue

Queue is a classic data structure. See Wiki's Queue for more details. The toolkit provides the following queue:

  • Queue — an adapter for lists.

Direct links

Direct links to files
Direct links to classes
  • Caches:
  • DLL:
    • Node — the foundational node class.
    • HeadNode — the class used by hosted DLL as the head node.
    • ValueNode — the class used by value-based DLL as the value node.
    • PtrBase — the base class for DLL pointers.
    • ExtListBase — the base class for DLL external lists.
    • List — the list class that implements node-based DLL.
    • ValueList — the list class that implements value-based DLL.
    • ExtList — the list class that implements an external headless node-based DLL.
    • ExtValueList — the list class that implements an external headless value-based DLL.
    • Ptr — the pointer class used by hosted DLL.
  • SLL:
    • Node — the foundational node class.
    • HeadNode — the class used by hosted SLL as the head node.
    • ValueNode — the class used by value-based SLL as the value node.
    • PtrBase — the base class for SLL pointers.
    • ExtListBase — the base class for SLL external lists.
    • SList — the list class that implements node-based SLL.
    • ValueSList — the list class that implements value-based SLL.
    • ExtSList — the list class that implements an external headless node-based SLL.
    • ExtValueSList — the list class that implements an external headless value-based SLL.
    • Ptr — the pointer class used by hosted SLL.
  • Heaps:
  • Queues:
    • Queue — the queue adapter class.