cleff-0.3.4.0: Fast and concise extensible effects
Copyright(c) 2021 Xy Ren
LicenseBSD3
Maintainerxy.r@outlook.com
Stabilityunstable
Portabilitynon-portable (GHC only)
Safe HaskellNone
LanguageHaskell2010

Data.RadixVec

Description

 
Synopsis

Documentation

data RadixVec a Source #

An efficient vector type, implemented as a radix tree. It has the following time complexities:

  • Lookup: \( O(\log n) \)
  • Update: \( O(\log n) \)
  • Append: \( O(\log n) \)

The branching factor (base of log) is 32 therefore the time is close to constant in most cases. Note that in practice, lookup is faster than update, and update is faster than append.

size :: RadixVec a -> Int Source #

Get the size of the RadixVec.

empty :: RadixVec a Source #

The empty RadixVec.

lookup :: Int -> RadixVec a -> a Source #

Lookup in a RadixVec by an index. This does not perform any bounds check.

update :: Int -> a -> RadixVec a -> RadixVec a Source #

Update a value in a RadixVec by an index. The value will be forced before installing. This does not perform any bounds check.

snoc :: RadixVec a -> a -> RadixVec a Source #

Append a value to a RadixVec. The value will be forced before installing. This does not perform any bounds check.