A tree based immutable map.
An immutable, ordered, extensional set
An immutable, ordered, extensional set
This data-structure maintains balance using the [AVL](https://en.wikipedia.org/wiki/AVL_tree) algorithm.
A fast, immutable BitSet.
A fast, immutable BitSet.
A Bitset is a specialized type of set that tracks the Int
values
it contains: for each integer value, a BitSet uses a single bit to
track whether the value is present (1) or absent (0). Bitsets are
often sparse, since "missing" bits can be assumed to be zero.
Unlike scala's default immutable this BitSet does not do a full copy on each added value.
Internally the implementation is a tree. Each leaf uses an Array[Long] value to hold up to 2048 bits, and each branch uses an Array[BitSet] to hold up to 32 subtrees (null subtrees are treated as empty).
Bitset treats the values it stores as 32-bit unsigned values, which
is relevant to the internal addressing methods as well as the order
used by iterator
.
The benchmarks suggest this bitset is MUCH faster than Scala's built-in bitset for cases where you may need many modifications and merges, (for example in a BloomFilter).
Dequeue - A Double Ended Queue
Dequeue - A Double Ended Queue
Front Back
<- uncons --------- unsnoc -> cons -> --------- <- snoc
Based on the Bankers Double Ended Queue as described by C. Okasaki in "Purely Functional Data Structures"
A queue that allows items to be put onto either the front (cons) or the back (snoc) of the queue in constant time, and constant time access to the element at the very front or the very back of the queue. Dequeuing an element from either end is constant time when amortized over a number of dequeues.
This queue maintains an invariant that whenever there are at least two elements in the queue, neither the front list nor back list are empty. In order to maintain this invariant, a dequeue from either side which would leave that side empty constructs the resulting queue by taking elements from the opposite side
Discrete Interval Encoding Tree (Diet).
Discrete Interval Encoding Tree (Diet). It stores subsets of types having a total order, a predecessor and a successor function described by Discrete[A]
Diet is a binary search tree where each node contains a range of values and the set of all nodes is a set of disjoint sets.
In the best case, when there are no "holes" in the stored set, the interval representation consists of just one single interval (node) and finding, inserting and deleting operations are O(1). In the worse case, where there are not two adjacent elements in the set, the representation is equivalent to a binary search tree.
Represent discrete operations that can be performed on A
Heap
is a Purely Functional Binary Heap.
Heap
is a Purely Functional Binary Heap. Binary Heaps are not common in the functional space, especially because
their implementation depends on mutable arrays in order to gain in performance. This functional binary heap is based
on Vladimir Kostyukov's paper and it does support the basic operations on a heap without compromising performance.
It is important to note that we can, in fact, to create the Binary Heap in order O(n) from a List
using the
function heapify
.
A PairingHeap is a heap with excellent empirical performance.
A PairingHeap is a heap with excellent empirical performance.
See: https://en.wikipedia.org/wiki/Pairing_heap in particular: https://en.wikipedia.org/wiki/Pairing_heap#Summary_of_running_times
Additionally, it supports an efficient O(1) combine operation
This is a typeclass for Heap-like data-structures which are not totally ordered sets, but can produce the minimimum value, add and remove items.
An intensional set, which is a set which instead of enumerating its elements as a extensional set does, it is defined by a predicate which is a test for membership.
Represent an inclusive range [x, y] that can be generated by using discrete operations
Implementation of "Purely Functional Random Access Lists" by Chris Okasaki.
Implementation of "Purely Functional Random Access Lists" by Chris Okasaki. This gives O(1) cons and uncons, and 2 log_2 N lookup.
A consequence of the log N complexity is that naive recursion on the inner methods will (almost) never blow the stack since the depth of the structure is log N, this greatly simplifies many methods. A key example is that unlike List, using a TreeList you can sequence and traverse very large lists without blowing the stack since the stack depth is only log N.
This data-structure is useful when you want fast cons and uncons, but also want to index. It does not have an optimized concatenation.
(Since version cats-collections 0.8.0) ISet has been renamed to Predicate.
(Since version cats-collections 0.8.0) ISet has been renamed to Predicate.