# compressedSegmentedTrie

> **compressedSegmentedTrie**<`V`>(`entries?`): [`SegmentedTrie`](/reference/knotkit/trie/interfaces/segmentedtrie/)<`V`>

Defined in: [packages/trie/src/compressed-segmented-trie.ts:186](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/trie/src/compressed-segmented-trie.ts#L186)

Create a [SegmentedTrie](/reference/knotkit/trie/interfaces/segmentedtrie/) that packs runs of non-branching segments into edge labels: the path compression a radix tree applies to characters, applied here to whole segments.

A node exists only where keys branch or end. Keys always end at nodes: an insert whose key runs out inside an edge splits the edge around a fresh node. `delete` prunes nodes it empties and folds a resulting single-child chain back into its parent’s edge, so the layout holds one node per branch point or key end of the live keys, whatever the operation history.

The observable contract matches [uncompressedSegmentedTrie](/reference/knotkit/trie/functions/uncompressedsegmentedtrie/) exactly. The trade is in the constants: fewer nodes, and one `Map` lookup per edge instead of one per segment during a walk, against edge comparisons on every operation and split bookkeeping on insert. Prefer it when keys are deep or mostly non-branching, the shapes that also make its smaller node count matter.

## Type Parameters

### V

`V`

## Parameters

### entries?

`Iterable`<[`SegmentedTrieEntry`](/reference/knotkit/trie/interfaces/segmentedtrieentry/)<`V`>, `any`, `any`>

Key-value pairs to store, in iteration order. A repeated key overwrites the earlier value, mirroring `Map`, and entries before an invalid one stay stored.

## Returns

[`SegmentedTrie`](/reference/knotkit/trie/interfaces/segmentedtrie/)<`V`>

## Throws

When an entry key is not an array of strings.
