dawg-ord-0.5.1.2: Directed acyclic word graphs

Safe HaskellNone
LanguageHaskell2010

Data.DAWG.Ord

Contents

Description

A version of Data.DAWG.Int adapted to keys and values with Ord instances.

Synopsis

DAWG type

data DAWG a b Source #

A directed acyclic word graph (DAWG) with type a representing the type of alphabet symbols (over which keys are constructed) and type b -- the type of values.

A DAWG can be seen as a map from keys (sequences of a's) to values b.

Instances
(Eq a, Eq b) => Eq (DAWG a b) Source # 
Instance details

Defined in Data.DAWG.Ord.Dynamic

Methods

(==) :: DAWG a b -> DAWG a b -> Bool #

(/=) :: DAWG a b -> DAWG a b -> Bool #

(Ord a, Ord b) => Ord (DAWG a b) Source # 
Instance details

Defined in Data.DAWG.Ord.Dynamic

Methods

compare :: DAWG a b -> DAWG a b -> Ordering #

(<) :: DAWG a b -> DAWG a b -> Bool #

(<=) :: DAWG a b -> DAWG a b -> Bool #

(>) :: DAWG a b -> DAWG a b -> Bool #

(>=) :: DAWG a b -> DAWG a b -> Bool #

max :: DAWG a b -> DAWG a b -> DAWG a b #

min :: DAWG a b -> DAWG a b -> DAWG a b #

(Show a, Show b) => Show (DAWG a b) Source # 
Instance details

Defined in Data.DAWG.Ord.Dynamic

Methods

showsPrec :: Int -> DAWG a b -> ShowS #

show :: DAWG a b -> String #

showList :: [DAWG a b] -> ShowS #

type ID = Int Source #

Identifier of a DAWG node (automaton state).

root :: DAWG a b -> ID Source #

The root (start state) of the DAWG.

Query

lookup :: Ord a => [a] -> DAWG a b -> Maybe b Source #

Find value associated with the key.

numStates :: DAWG a b -> Int Source #

Number of states in the underlying automaton.

numEdges :: DAWG a b -> Int Source #

Number of transitions in the underlying automaton.

Traversal

value :: ID -> DAWG a b -> Maybe b Source #

Value stored in the given automaton state.

edges :: ID -> DAWG a b -> [(a, ID)] Source #

A list of outgoing edges (automaton transitions).

follow :: Ord a => ID -> a -> DAWG a b -> Maybe ID Source #

Follow a transition with the given symbol from the given state.

Construction

empty :: DAWG a b Source #

Empty DAWG.

fromList :: (Ord a, Ord b) => [([a], b)] -> DAWG a b Source #

Construct DAWG from the list of (key, value) pairs.

fromLang :: Ord a => [[a]] -> DAWG a () Source #

Make DAWG from the list of words (annotate each word with the () value).

Insertion

insert :: (Ord a, Ord b) => [a] -> b -> DAWG a b -> DAWG a b Source #

Insert the (key, value) pair into the DAWG.

Conversion

assocs :: DAWG a b -> [([a], b)] Source #

Return all key/value pairs in the DAWG in ascending key order.

keys :: DAWG a b -> [[a]] Source #

Return all keys of the DAWG in ascending order.

elems :: DAWG a b -> [b] Source #

Return all elements of the DAWG in the ascending order of their keys.