Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Immutable Vector #362

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions immutable_vec/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Immutable Vector

Based on Clojure's [persistent vector](https://hypirion.com/musings/understanding-persistent-vector-pt-1).

Currently, only `push`, `set` and `get` are implemented, alongside with some iteration functions.

## TODO

- Add `insert` and `delete`.
- Support tail optimization.
Based on *RRB Vector: A Practical General Purpose Immutable Sequence, ICFP'15*.

It supports normal vector operations ($m$ is the branching factor and $n$ is the number of elements):
- Indexing in $O(\log_2{m} \cdot \log_m{n})$
- Updating in $O(m \cdot \log_m{n})$
- Removal in $O(m^2 \cdot \log_m{n})$
- Appending in $O(m \cdot \log_m{n})$
- Splitting in $O(m \cdot \log_m{n})$
- Concatenation in $O(m^2 \cdot \log_m{n})$