Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SandroMaglione committed Jan 22, 2024
1 parent 5179ad0 commit 8858334
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- [Getters](#getters)
- [🛠️ Properties](#️-properties)
- [Immutable](#immutable)
- [Thread safe](#thread-safe)
- [Stack safe](#stack-safe)
- [(Space) Efficient](#space-efficient)
- [📃 Versioning](#-versioning)
- [😀 Support](#-support)
Expand Down Expand Up @@ -121,7 +121,7 @@ expect(newITrie.length, 1);

> ✅ Immutability in `ITrie` uses a technique called **Path copying**: this makes `ITrie` efficient since it does not require to copy the full data structure with every mutation
### Thread safe
### Stack safe
`ITrie` does **not** use recursion. No matter how many operations or elements it contains, `ITrie` will never cause stack overflow issues.

### (Space) Efficient
Expand Down
17 changes: 11 additions & 6 deletions lib/src/itrie_base.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/// {@template immutable_notice}
/// [ITrie] is immutable: this method returns a copy of the original
/// [ITrie] without modifying the original [ITrie]
/// {@endtemplate}
class _Node<V> {
final String key;
V? value;
Expand Down Expand Up @@ -92,6 +87,13 @@ class _ITrieIterator<V> implements Iterator<(String, V)> {
}
}

/// [ITrie] is used for locating specific string keys from within a set.
///
/// [ITrie] is often used to store a dictionary (list of words) that can be searched
/// in a manner that allows for efficient generation of completion lists
/// (e.g. predict the rest of a word a user is typing).
///
/// [ITrie] is **efficient, immutable and stack safe**.
class ITrie<V> extends Iterable<(String, V)> {
final _Node<V>? _root;
final int _count;
Expand Down Expand Up @@ -121,7 +123,10 @@ class ITrie<V> extends Iterable<(String, V)> {
///
/// If `key` is already present its previous value is overwritten with `value`
///
/// {@macro immutable_notice}
/// {@template immutable_notice}
/// [ITrie] is immutable: this method returns a copy of the original
/// [ITrie] without modifying the original [ITrie]
/// {@endtemplate}
///
/// {@category Mutation}
ITrie<V> insert(String key, V value) {
Expand Down

0 comments on commit 8858334

Please sign in to comment.