Completed
Push — master ( 4069b9...1bd80c )
by Siro Díaz
02:06
created

TrieTree::size()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * DataStructures for PHP
4
 *
5
 * @link      https://github.com/SiroDiaz/DataStructures
6
 * @copyright Copyright (c) 2017 Siro Díaz Palazón
7
 * @license   https://github.com/SiroDiaz/DataStructures/blob/master/README.md (MIT License)
8
 */
9
namespace DataStructures\Trees;
10
11
/**
12
 * TrieTree
13
 *
14
 * The TrieTree class is a trie (also called digital tree and sometimes radix tree or prefix tree)
15
 * that is used to get in O(m) being m the word length.
16
 * It is used in software like word corrector and word suggest.
17
 *
18
 * @author Siro Diaz Palazon <[email protected]>
19
 */
20
class TrieTree implements Countable {
21
    private $root;
22
    private $numWords;
23
    private $size;
24
    
25
    public function __construct() {
26
        $this->root = null;
27
        $this->numWords = 0;
28
        $this->size = 0;
29
    }
30
31
    public function numWords() : int {
32
        return $this->numWords;
33
    }
34
35
    public function size() : int {
36
        return $this->size;
37
    }
38
39
    public function count() {
40
        return $this->size();
41
    }
42
}