Skip to content

Instantly share code, notes, and snippets.

View ryanberckmans's full-sized avatar

Ryan Berckmans ryanberckmans

View GitHub Profile
@ryanberckmans
ryanberckmans / doubleLinkedList.scala
Created September 28, 2022 03:12
A doubly-linked list in Scala
import scala.annotation.tailrec
import com.thoughtworks.enableIf
// Doubly-linked lists allow O(1) removals at the cost of having a
// reference to the doubly-linked node itself. Some game objects store
// their own next/prev links, which allows for a convenient reference to
// the doubly-linked node (i.e. it's just the value stored) however then
// each value can partake in at most one list at a time (per next/prev,
// can have multiple types of next/prev as is done with Affect).