Module

Data.Search.Trie.Internal

Package
purescript-search-trie
Repository
klntsky/purescript-search-trie

#Trie Source

data Trie k v

Constructors

Instances

#Ctx Source

data Ctx k v

Constructors

#Zipper Source

data Zipper k v

Constructors

#alter Source

alter :: forall k v. Ord k => List k -> (Maybe v -> Maybe v) -> Trie k v -> Trie k v

Delete, insert or update the entry by a given path. It is recommended to use specialized functions for each case.

#delete Source

delete :: forall k v. Ord k => List k -> Trie k v -> Trie k v

Delete the entry at a given path.

#deleteByPrefix Source

deleteByPrefix :: forall k v. Ord k => List k -> Trie k v -> Trie k v

Delete all entries by a given path prefix.

#descend Source

descend :: forall k v. Ord k => List k -> Zipper k v -> { mbValue :: Maybe v, children :: Map k (Trie k v), ctxs :: List (Ctx k v) }

Follows a given path, constructing new branches as necessary. Returns the contents of the last branch with context from which the trie can be restored using fromZipper.

#entries Source

entries :: forall k v. Trie k v -> List (Tuple (List k) v)

Resulting List will be sorted.

#entriesUnordered Source

entriesUnordered :: forall k v. Trie k v -> List (Tuple (List k) v)

A version of entries defined using Data.Map.toUnfoldableUnordered.

#eq' Source

eq' :: forall k v. Eq k => Eq v => Trie k v -> Trie k v -> Boolean

Check that two tries are not only equal, but also have the same internal structure.

#follow Source

follow :: forall k v. Ord k => List k -> Zipper k v -> Maybe { mbValue :: Maybe v, children :: Map k (Trie k v), ctxs :: List (Ctx k v) }

Follows a given path, but unlike descend, fails instead of creating new branches.

#fromFoldable Source

fromFoldable :: forall f p k v. Ord k => Foldable f => Foldable p => f (Tuple (p k) v) -> Trie k v

#fromList Source

fromList :: forall k v. Ord k => List (Tuple (List k) v) -> Trie k v

#fromZipper Source

fromZipper :: forall k v. Ord k => Zipper k v -> Trie k v

#insert Source

insert :: forall k v. Ord k => List k -> v -> Trie k v -> Trie k v

Insert an entry into a trie.

#isEmpty Source

isEmpty :: forall k v. Trie k v -> Boolean

#lookup Source

lookup :: forall k v. Ord k => List k -> Trie k v -> Maybe v

#mkZipper Source

mkZipper :: forall k v. Trie k v -> Zipper k v

#prune Source

prune :: forall k v. Ord k => List (Ctx k v) -> Zipper k v

Delete everything until the first non-empty context.

#query Source

query :: forall k v. Ord k => List k -> Trie k v -> List (Tuple (List k) v)

#queryValues Source

queryValues :: forall k v. Ord k => List k -> Trie k v -> List v

#size Source

size :: forall k v. Trie k v -> Int

Number of elements in a trie.

#subtrie Source

subtrie :: forall k v. Ord k => List k -> Trie k v -> Maybe (Trie k v)

Returns a subtrie containing all paths with given prefix. Path prefixes are not saved.

#subtrieWithPrefixes Source

subtrieWithPrefixes :: forall k v. Ord k => List k -> Trie k v -> Maybe (Trie k v)

A version of subtrie that does not cut the prefixes.

#toUnfoldable Source

toUnfoldable :: forall f p k v. Unfoldable f => Unfoldable p => Trie k v -> f (Tuple (p k) v)

#update Source

update :: forall k v. Ord k => (v -> v) -> List k -> Trie k v -> Trie k v

Update the entry at a given path.

#values Source

values :: forall k v. Trie k v -> List v