-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrie.mli
46 lines (40 loc) · 1.76 KB
/
trie.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(** [t] is the type of a Trie, initially will be only a string list list*)
type t
val empty : t
(** [add_word trie word] is [trie] after [word] is inserted into it
@param trie is the trie you want to add the word to
@param word is the word you want to insert into the trie
@return trie is the trie with the word inserted
Raises: No Exceptions
Example: [add_word t "hello"] returns trie with word inserted *)
val add_word : t -> string -> t
(** [add_words_from_file filename] is the trie generated by adding
all the words from file with name [filename] to an empty trie
@param filename is the filename you want to load words from
@return is the trie with all words from [filename] inserted
Raises: No Exceptions
Example: [add_word_from_file "words.txt"] will populate a trie with
words from words.txt *)
val add_words_from_file : string -> t
(** [contains trie word] is whether or not [word] is contained within
[trie]
@param trie is the trie to check
@param word is the word you are checking for in trie
@return true/false dependng whether or not [word]
Raises: No Exceptions
Example: [contains t "hi"] = true *)
val contains : t -> string -> bool
(** [contains_prefix trie pref] is whether or not a word with prefix [pref]
has been added to [trie]
@param trie is the trie to check
@param pref is the prefix to check whether in trie
@return true/false depending on whether prefix is in the trie
Raises: No Exceptions
Example: [contains_prefix t "cat"] = true*)
val contains_prefix : t -> string -> bool
(** [to_list trie] is [trie] in the form of a string list
@param trie is the trie to convert to a list
@return string list containing the words in the trie
Raises: No Exceptions
Example: [to_list t] = ["hello"; "hi"]*)
val to_list : t -> string list