Skip to content

Commit a94abdd

Browse files
committed
Update README.
1 parent ad76109 commit a94abdd

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

README.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,25 @@ API documentation is automatically generated with [APIGen](https://github.com/Ap
2626

2727
## Usage
2828

29-
The object has to be used just like a regular array.
30-
3129
```php
32-
$tree = new drupol\phptree\Merkle();
30+
use drupol\phptree\Node\ValueNode;
31+
use drupol\phptree\Node\KeyValueNode;
32+
33+
$tree = new KeyValueNode('root');
3334

34-
$tree[] = 'hello';
35-
$tree[] = 'world';
35+
$nodes = [];
36+
foreach (\range('a', 'e') as $lowercaseValue) {
37+
$node1 = new ValueNode($lowercaseValue);
3638

37-
$tree->hash(); // this returns: b9187808075710ab9c447c6ff6fd2aeb6c4bc10cf752e849102b87c0ecf97824
39+
foreach (\range('A', 'E') as $uppercaseValue) {
40+
$node2 = new ValueNode($uppercaseValue);
41+
$node1->add($node2);
42+
}
3843

39-
$tree['key'] = 'value';
44+
$nodes[] = $node1;
45+
}
4046

41-
$tree['key']; // this returns: 'value';
47+
$tree->add(...$nodes);
4248
```
4349

4450
## Code quality, tests and benchmarks

0 commit comments

Comments
 (0)