Options
All
  • Public
  • Public/Protected
  • All
Menu

File LinkedList

A sequence of values, organized in-memory as a strict linked list. Each element has an head (value) and a tail (the rest of the list).

The code is organized through the class EmptyLinkedList (empty list or tail), the class ConsLinkedList (list value and pointer to next), and the type alias LinkedList (empty or cons).

Finally, "static" functions on Option are arranged in the class LinkedListStatic and are accessed through the global constant LinkedList.

Random access is expensive, appending is expensive, prepend or getting the tail of the list is very cheap. If you often need random access you should rather use Vector. Avoid appending at the end of the list in a loop, prefer prepending and then reversing the list.

Examples:

LinkedList.of(1,2,3);
LinkedList.of(1,2,3).map(x => x*2).last();

Index

Type aliases

LinkedList

LinkedList: EmptyLinkedList<T> | ConsLinkedList<T>

A LinkedList is either EmptyLinkedList or ConsLinkedList "static methods" available through LinkedListStatic

param

the item type

Variables

LinkedList

LinkedList: LinkedListStatic = new LinkedListStatic()

The LinkedList constant allows to call the LinkedList "static" methods

Generated using TypeDoc