Liking cljdoc? Tell your friends :D

ordered-collections.types.byte-rope

Persistent byte rope optimized for structural editing of binary data. Backed by a chunked weight-balanced tree with byte[] chunks. O(log n) concat, split, splice, insert, and remove.

Bytes are exposed as unsigned longs in [0, 255]. Storage is signed Java bytes (same bits). Equality with byte[] is content-based; equality with Clojure vectors is always false to avoid signed/unsigned confusion.

Small byte sequences (≤ +flat-threshold+ bytes) are stored as a raw byte[] internally, giving byte[]-equivalent performance on reads. When edits grow past the threshold, the representation is transparently promoted to chunked tree form.

Persistent byte rope optimized for structural editing of binary data.
Backed by a chunked weight-balanced tree with byte[] chunks.
O(log n) concat, split, splice, insert, and remove.

Bytes are exposed as unsigned longs in [0, 255]. Storage is signed Java
bytes (same bits). Equality with byte[] is content-based; equality with
Clojure vectors is always false to avoid signed/unsigned confusion.

Small byte sequences (≤ +flat-threshold+ bytes) are stored as a raw
byte[] internally, giving byte[]-equivalent performance on reads. When
edits grow past the threshold, the representation is transparently
promoted to chunked tree form.
raw docstring

ordered-collections.types.fuzzy-map

A map that returns the value associated with the closest key.

When looking up a key, returns the value for the key in the map that is closest to the query. For numeric keys, distance is |query - key|.

Tie-breaking: When two keys are equidistant, use :< to prefer the smaller key, or :> to prefer the larger key.

A map that returns the value associated with the closest key.

When looking up a key, returns the value for the key in the map that is
closest to the query. For numeric keys, distance is |query - key|.

Tie-breaking: When two keys are equidistant, use :< to prefer the
smaller key, or :> to prefer the larger key.
raw docstring

ordered-collections.types.fuzzy-set

A set that returns the closest element to a query.

When looking up a value, returns the element in the set that is closest to the query. For numeric keys, distance is |query - element|.

Tie-breaking: When two elements are equidistant, use :< to prefer the smaller element, or :> to prefer the larger element.

A set that returns the closest element to a query.

When looking up a value, returns the element in the set that is closest
to the query. For numeric keys, distance is |query - element|.

Tie-breaking: When two elements are equidistant, use :< to prefer the
smaller element, or :> to prefer the larger element.
raw docstring

ordered-collections.types.interop

Protocol extensions for interoperability with standard Clojure collections.

Extends ordered-collections protocols to:

  • PersistentHashSet
  • PersistentTreeSet
  • PersistentTreeMap

This allows protocol functions like union, intersection, nearest, etc. to work with standard Clojure sorted collections.

Protocol extensions for interoperability with standard Clojure collections.

Extends ordered-collections protocols to:
- PersistentHashSet
- PersistentTreeSet
- PersistentTreeMap

This allows protocol functions like union, intersection, nearest, etc.
to work with standard Clojure sorted collections.
raw docstring

No vars found in this namespace.

ordered-collections.types.interval-map

No vars found in this namespace.

ordered-collections.types.interval-set

No vars found in this namespace.

ordered-collections.types.ordered-multiset

Persistent sorted multiset (bag) backed by a weight-balanced tree.

Internally an ordered map from elements to counts (longs). The public API expands each entry into repeated elements: an element with count 3 appears three times in seq, reduce, and nth.

Persistent sorted multiset (bag) backed by a weight-balanced tree.

Internally an ordered map from elements to counts (longs). The public
API expands each entry into repeated elements: an element with count 3
appears three times in seq, reduce, and nth.
raw docstring

ordered-collections.types.ordered-set

No vars found in this namespace.

ordered-collections.types.priority-queue

Persistent priority queue backed by a weight-balanced tree.

Internally an ordered map from priorities to vectors of values. Duplicate priorities are stable in insertion order. The public API exposes [priority value] pairs; the vector grouping is hidden.

Persistent priority queue backed by a weight-balanced tree.

Internally an ordered map from priorities to vectors of values. Duplicate
priorities are stable in insertion order. The public API exposes
[priority value] pairs; the vector grouping is hidden.
raw docstring

ordered-collections.types.range-map

A map from non-overlapping ranges to values.

Unlike IntervalMap (which allows overlapping intervals), RangeMap enforces that ranges never overlap. When inserting a new range, any overlapping portions of existing ranges are removed.

SEMANTICS (compatible with Guava's TreeRangeMap):

  • assoc (put): inserts range, carving out overlaps. Does NOT coalesce.
  • assoc-coalescing (putCoalescing): inserts and coalesces adjacent same-value ranges.

RANGE SEMANTICS: Ranges are half-open intervals [lo, hi) by default:

  • [0 10] contains 0, 1, 2, ..., 9 but NOT 10

PERFORMANCE:

  • Point lookup: O(log n)
  • Insert/assoc: O(k log n) where k = number of overlapping ranges
  • Coalescing insert: O(k log n)
  • Remove: O(k log n) For typical use (k=1-3 overlaps), effectively O(log n).
A map from non-overlapping ranges to values.

Unlike IntervalMap (which allows overlapping intervals), RangeMap enforces
that ranges never overlap. When inserting a new range, any overlapping
portions of existing ranges are removed.

SEMANTICS (compatible with Guava's TreeRangeMap):
- `assoc` (put): inserts range, carving out overlaps. Does NOT coalesce.
- `assoc-coalescing` (putCoalescing): inserts and coalesces adjacent
  same-value ranges.

RANGE SEMANTICS:
Ranges are half-open intervals [lo, hi) by default:
- [0 10] contains 0, 1, 2, ..., 9 but NOT 10

PERFORMANCE:
- Point lookup: O(log n)
- Insert/assoc: O(k log n) where k = number of overlapping ranges
- Coalescing insert: O(k log n)
- Remove: O(k log n)
For typical use (k=1-3 overlaps), effectively O(log n).
raw docstring

ordered-collections.types.rope

Persistent rope-like indexed sequence backed by an implicit-index weight-balanced tree.

Persistent rope-like indexed sequence backed by an implicit-index
weight-balanced tree.
raw docstring

ordered-collections.types.segment-tree

A segment tree for efficient range aggregate queries.

Supports O(log n) point updates and O(log n) range queries for any associative operation (sum, min, max, gcd, etc.).

CONCEPT: Each node stores an aggregate of its entire subtree. For sum:

             ┌─────────────┐
             │ key: 3      │
             │ val: 40     │
             │ agg: 150 ◄──────── sum of entire tree
             └──────┬──────┘
        ┌───────────┴───────────┐
 ┌──────┴──────┐         ┌──────┴──────┐
 │ key: 1      │         │ key: 4      │
 │ val: 20     │         │ val: 50     │
 │ agg: 30 ◄───────      │ agg: 80 ◄───────
 └──────┬──────┘   │     └──────┬──────┘   │
        │          │            │          │
 ┌──────┴──────┐   │     ┌──────┴──────┐   │
 │ key: 0      │   │     │ key: 5      │   │
 │ val: 10     │   │     │ val: 30     │   │
 │ agg: 10     │   │     │ agg: 30     │   │
 └─────────────┘   │     └─────────────┘   │
                   │                       │
        10 + 20 = 30              50 + 30 = 80

RANGE QUERY: query(1, 4) = sum of indices 1,2,3,4 Uses aggregates to avoid visiting every node - O(log n).

EXAMPLE: (def st (segment-tree + 0 {0 10, 1 20, 2 30, 3 40, 4 50})) (query st 0 4) ; => 150 (sum of all) (query st 1 3) ; => 90 (20 + 30 + 40) (update st 2 100) ; => new tree with index 2 = 100 (query st 1 3) ; => 160 (20 + 100 + 40)

A segment tree for efficient range aggregate queries.

Supports O(log n) point updates and O(log n) range queries for any
associative operation (sum, min, max, gcd, etc.).

CONCEPT:
Each node stores an aggregate of its entire subtree. For sum:

                 ┌─────────────┐
                 │ key: 3      │
                 │ val: 40     │
                 │ agg: 150 ◄──────── sum of entire tree
                 └──────┬──────┘
            ┌───────────┴───────────┐
     ┌──────┴──────┐         ┌──────┴──────┐
     │ key: 1      │         │ key: 4      │
     │ val: 20     │         │ val: 50     │
     │ agg: 30 ◄───────      │ agg: 80 ◄───────
     └──────┬──────┘   │     └──────┬──────┘   │
            │          │            │          │
     ┌──────┴──────┐   │     ┌──────┴──────┐   │
     │ key: 0      │   │     │ key: 5      │   │
     │ val: 10     │   │     │ val: 30     │   │
     │ agg: 10     │   │     │ agg: 30     │   │
     └─────────────┘   │     └─────────────┘   │
                       │                       │
            10 + 20 = 30              50 + 30 = 80

RANGE QUERY: query(1, 4) = sum of indices 1,2,3,4
Uses aggregates to avoid visiting every node - O(log n).

EXAMPLE:
  (def st (segment-tree + 0 {0 10, 1 20, 2 30, 3 40, 4 50}))
  (query st 0 4)     ; => 150 (sum of all)
  (query st 1 3)     ; => 90 (20 + 30 + 40)
  (update st 2 100)  ; => new tree with index 2 = 100
  (query st 1 3)     ; => 160 (20 + 100 + 40)
raw docstring

ordered-collections.types.string-rope

Persistent string rope optimized for structural text editing. Backed by a chunked weight-balanced tree with String chunks. O(log n) concat, split, splice, insert, and remove. Implements CharSequence for seamless Java interop.

Small strings (≤ +flat-threshold+ chars) are stored as a raw String internally, giving String-equivalent performance on read operations. When edits grow the content past the threshold, the representation is transparently promoted to the chunked tree form.

Persistent string rope optimized for structural text editing.
Backed by a chunked weight-balanced tree with String chunks.
O(log n) concat, split, splice, insert, and remove.
Implements CharSequence for seamless Java interop.

Small strings (≤ +flat-threshold+ chars) are stored as a raw String
internally, giving String-equivalent performance on read operations.
When edits grow the content past the threshold, the representation
is transparently promoted to the chunked tree form.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close