# tlemane/cds architecture

> Architecture diagram of the GitHub repository tlemane/cds, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tlemane/cds
- Repository: https://github.com/tlemane/cds

## Overview

cds is a header-only C++23 library for packed containers, succinct indexes, and compressed sequences. A typical workflow builds or views a bit source, constructs rank/select indexes, and uses those queries directly or through higher-level structures such as Elias–Fano and wavelet matrices. Packed integer containers provide a foundational storage layer; bit containers specialize it, while broadword operations support succinct algorithms. The README documents serialization and zero-copy views backed by buffers, files, or mmap. Some subsystem links below reflect README-level capability descriptions; unsampled implementation details are not inferred.

Main entry points: [`include/cds/bit/interface.hpp`](https://github.com/tlemane/cds/blob/main/include/cds/bit/interface.hpp) (Bit source API), [`include/cds/rank/rank9.hpp`](https://github.com/tlemane/cds/blob/main/include/cds/rank/rank9.hpp) (Rank9 index), [`include/cds/select/darray.hpp`](https://github.com/tlemane/cds/blob/main/include/cds/select/darray.hpp) (Darray select), [`include/cds/bit_dict.hpp`](https://github.com/tlemane/cds/blob/main/include/cds/bit_dict.hpp) (Bit dictionary)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_containers["Packed containers"]
  node_packed_vector["Packed vector<br/>[vector.hpp]"]
  node_packed_array["Packed array<br/>[array.hpp]"]
  node_packed_view["Packed view<br/>[view.hpp]"]
  node_packer["Packed operations<br/>[packer.hpp]"]
  node_bit_source["Bit source API<br/>[interface.hpp]"]
  node_bit_vector["Bit vector<br/>[vector.hpp]"]
  node_bit_array["Bit array<br/>[array.hpp]"]
  node_bit_view["Bit view<br/>[view.hpp]"]
end

subgraph group_indexes["Rank and select"]
  node_broadword["Broadword primitives<br/>[broadword.hpp]"]
  node_rank9["Rank9 index<br/>[rank9.hpp]"]
  node_rank_poppy["Poppy rank<br/>[poppy.hpp]"]
  node_rank_scan["Scan rank<br/>[scan.hpp]"]
  node_darray["Darray select<br/>[darray.hpp]"]
  node_select9["Select9 index<br/>[select9.hpp]"]
  node_select_poppy["Poppy select<br/>[poppy.hpp]"]
  node_select_scan["Scan select<br/>[scan.hpp]"]
end

subgraph group_compressed["Compressed structures"]
  node_bit_dict["Bit dictionary<br/>[bit_dict.hpp]"]
  node_ef["Elias–Fano<br/>[ef.hpp]"]
  node_rrr["RRR bit vector<br/>[rrr.hpp]"]
end

subgraph group_sequences["Sequence indexes"]
  node_wavelet["Wavelet matrix<br/>[wavelet_matrix.hpp]"]
end

subgraph group_io["Serialization and views"]
  node_io_buffer["I/O buffers<br/>[buffer.hpp]"]
  node_io_file["File I/O<br/>[file.hpp]"]
  node_mmap["Memory mapping<br/>[mmap.hpp]"]
end

node_user(("Library user"))

node_user -->|"builds"| node_packed_vector
node_user -->|"builds"| node_bit_vector
node_user -->|"queries"| node_rank9
node_user -->|"queries"| node_darray
node_user -->|"queries"| node_ef
node_user -->|"queries"| node_rrr
node_user -->|"queries"| node_wavelet
node_packed_vector -.->|"packs elements"| node_packer
node_packed_array -.->|"packs elements"| node_packer
node_bit_vector -->|"models"| node_bit_source
node_bit_array -->|"models"| node_bit_source
node_bit_view -->|"models"| node_bit_source
node_rank9 -->|"indexes bits"| node_bit_source
node_rank_poppy -->|"indexes bits"| node_bit_source
node_rank_scan -->|"scans bits"| node_bit_source
node_darray -->|"selects bits"| node_bit_source
node_select9 -->|"builds on"| node_rank9
node_select_poppy -->|"builds on"| node_rank_poppy
node_rank9 -.->|"uses primitives"| node_broadword
node_rank_poppy -.->|"uses primitives"| node_broadword
node_darray -.->|"uses primitives"| node_broadword
node_bit_dict -->|"bundles bits"| node_bit_vector
node_bit_dict -->|"bundles rank"| node_rank9
node_bit_dict -->|"bundles select"| node_darray
node_ef -->|"defaults to"| node_darray
node_rrr -->|"compresses bits"| node_bit_source
node_wavelet -->|"uses levels"| node_bit_dict
node_wavelet -->|"supports levels"| node_rrr
node_packed_vector -->|"viewable as"| node_packed_view
node_bit_vector -->|"viewable as"| node_bit_view
node_io_buffer -.->|"backs views"| node_packed_view
node_io_file -.->|"backs views"| node_packed_view
node_mmap -.->|"backs views"| node_packed_view

click node_packed_vector "https://github.com/tlemane/cds/blob/main/include/cds/packed/vector.hpp"
click node_packed_array "https://github.com/tlemane/cds/blob/main/include/cds/packed/array.hpp"
click node_packed_view "https://github.com/tlemane/cds/blob/main/include/cds/packed/view.hpp"
click node_packer "https://github.com/tlemane/cds/blob/main/include/cds/core/packed/packer.hpp"
click node_bit_source "https://github.com/tlemane/cds/blob/main/include/cds/bit/interface.hpp"
click node_bit_vector "https://github.com/tlemane/cds/blob/main/include/cds/bit/vector.hpp"
click node_bit_array "https://github.com/tlemane/cds/blob/main/include/cds/bit/array.hpp"
click node_bit_view "https://github.com/tlemane/cds/blob/main/include/cds/bit/view.hpp"
click node_broadword "https://github.com/tlemane/cds/blob/main/include/cds/core/broadword.hpp"
click node_rank9 "https://github.com/tlemane/cds/blob/main/include/cds/rank/rank9.hpp"
click node_rank_poppy "https://github.com/tlemane/cds/blob/main/include/cds/rank/poppy.hpp"
click node_rank_scan "https://github.com/tlemane/cds/blob/main/include/cds/rank/scan.hpp"
click node_darray "https://github.com/tlemane/cds/blob/main/include/cds/select/darray.hpp"
click node_select9 "https://github.com/tlemane/cds/blob/main/include/cds/select/select9.hpp"
click node_select_poppy "https://github.com/tlemane/cds/blob/main/include/cds/select/poppy.hpp"
click node_select_scan "https://github.com/tlemane/cds/blob/main/include/cds/select/scan.hpp"
click node_bit_dict "https://github.com/tlemane/cds/blob/main/include/cds/bit_dict.hpp"
click node_ef "https://github.com/tlemane/cds/blob/main/include/cds/ef.hpp"
click node_rrr "https://github.com/tlemane/cds/blob/main/include/cds/rrr.hpp"
click node_wavelet "https://github.com/tlemane/cds/blob/main/include/cds/wavelet_matrix.hpp"
click node_io_buffer "https://github.com/tlemane/cds/blob/main/include/cds/io/buffer.hpp"
click node_io_file "https://github.com/tlemane/cds/blob/main/include/cds/io/file.hpp"
click node_mmap "https://github.com/tlemane/cds/blob/main/include/cds/io/mmap.hpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_packed_vector,node_packed_array,node_packed_view,node_packer,node_bit_source,node_bit_vector,node_bit_array,node_bit_view,node_user toneBlue
class node_broadword,node_rank9,node_rank_poppy,node_rank_scan,node_darray,node_select9,node_select_poppy,node_select_scan toneAmber
class node_bit_dict,node_ef,node_rrr toneMint
class node_wavelet toneRose
class node_io_buffer,node_io_file,node_mmap toneIndigo
```

## Components

### Packed containers

- [Packed vector](https://github.com/tlemane/cds/blob/main/include/cds/packed/vector.hpp): `include/cds/packed/vector.hpp`
- [Packed array](https://github.com/tlemane/cds/blob/main/include/cds/packed/array.hpp): `include/cds/packed/array.hpp`
- [Packed view](https://github.com/tlemane/cds/blob/main/include/cds/packed/view.hpp): `include/cds/packed/view.hpp`
- [Packed operations](https://github.com/tlemane/cds/blob/main/include/cds/core/packed/packer.hpp): `include/cds/core/packed/packer.hpp`
- [Bit source API](https://github.com/tlemane/cds/blob/main/include/cds/bit/interface.hpp): `include/cds/bit/interface.hpp`
- [Bit vector](https://github.com/tlemane/cds/blob/main/include/cds/bit/vector.hpp): `include/cds/bit/vector.hpp`
- [Bit array](https://github.com/tlemane/cds/blob/main/include/cds/bit/array.hpp): `include/cds/bit/array.hpp`
- [Bit view](https://github.com/tlemane/cds/blob/main/include/cds/bit/view.hpp): `include/cds/bit/view.hpp`

### Rank and select

- [Broadword primitives](https://github.com/tlemane/cds/blob/main/include/cds/core/broadword.hpp): `include/cds/core/broadword.hpp`
- [Rank9 index](https://github.com/tlemane/cds/blob/main/include/cds/rank/rank9.hpp): `include/cds/rank/rank9.hpp`
- [Poppy rank](https://github.com/tlemane/cds/blob/main/include/cds/rank/poppy.hpp): `include/cds/rank/poppy.hpp`
- [Scan rank](https://github.com/tlemane/cds/blob/main/include/cds/rank/scan.hpp): `include/cds/rank/scan.hpp`
- [Darray select](https://github.com/tlemane/cds/blob/main/include/cds/select/darray.hpp): `include/cds/select/darray.hpp`
- [Select9 index](https://github.com/tlemane/cds/blob/main/include/cds/select/select9.hpp): `include/cds/select/select9.hpp`
- [Poppy select](https://github.com/tlemane/cds/blob/main/include/cds/select/poppy.hpp): `include/cds/select/poppy.hpp`
- [Scan select](https://github.com/tlemane/cds/blob/main/include/cds/select/scan.hpp): `include/cds/select/scan.hpp`

### Compressed structures

- [Bit dictionary](https://github.com/tlemane/cds/blob/main/include/cds/bit_dict.hpp): `include/cds/bit_dict.hpp`
- [Elias–Fano](https://github.com/tlemane/cds/blob/main/include/cds/ef.hpp): `include/cds/ef.hpp`
- [RRR bit vector](https://github.com/tlemane/cds/blob/main/include/cds/rrr.hpp): `include/cds/rrr.hpp`

### Sequence indexes

- [Wavelet matrix](https://github.com/tlemane/cds/blob/main/include/cds/wavelet_matrix.hpp): `include/cds/wavelet_matrix.hpp`

### Serialization and views

- [I/O buffers](https://github.com/tlemane/cds/blob/main/include/cds/io/buffer.hpp): `include/cds/io/buffer.hpp`
- [File I/O](https://github.com/tlemane/cds/blob/main/include/cds/io/file.hpp): `include/cds/io/file.hpp`
- [Memory mapping](https://github.com/tlemane/cds/blob/main/include/cds/io/mmap.hpp): `include/cds/io/mmap.hpp`

### Other components

- **Library user**

## Connections

- Library user → Packed vector: builds
- Library user → Bit vector: builds
- Library user → Rank9 index: queries
- Library user → Darray select: queries
- Library user → Elias–Fano: queries
- Library user → RRR bit vector: queries
- Library user → Wavelet matrix: queries
- Packed vector → Packed operations: packs elements
- Packed array → Packed operations: packs elements
- Bit vector → Bit source API: models
- Bit array → Bit source API: models
- Bit view → Bit source API: models
- Rank9 index → Bit source API: indexes bits
- Poppy rank → Bit source API: indexes bits
- Scan rank → Bit source API: scans bits
- Darray select → Bit source API: selects bits
- Select9 index → Rank9 index: builds on
- Poppy select → Poppy rank: builds on
- Rank9 index → Broadword primitives: uses primitives
- Poppy rank → Broadword primitives: uses primitives
- Darray select → Broadword primitives: uses primitives
- Bit dictionary → Bit vector: bundles bits
- Bit dictionary → Rank9 index: bundles rank
- Bit dictionary → Darray select: bundles select
- Elias–Fano → Darray select: defaults to
- RRR bit vector → Bit source API: compresses bits
- Wavelet matrix → Bit dictionary: uses levels
- Wavelet matrix → RRR bit vector: supports levels
- Packed vector → Packed view: viewable as
- Bit vector → Bit view: viewable as
- I/O buffers → Packed view: backs views
- File I/O → Packed view: backs views
- Memory mapping → Packed view: backs views
