Class: Classbench::NodeStats
- Inherits:
-
Object
- Object
- Classbench::NodeStats
- Defined in:
- lib/classbench/trie.rb
Overview
Structure representing statistics related to trie nodes.
All the statistics are stored separately for each level of the trie.
Instance Attribute Summary collapse
-
#leaf ⇒ Object
(int[]) number of leaf nodes.
-
#non_prefix ⇒ Object
(int[]) number of non-prefix nodes.
-
#one_child ⇒ Object
(int[]) number of nodes with one child only.
-
#prefix ⇒ Object
(int[]) number of prefix nodes (not prefixes).
-
#two_children ⇒ Object
(int[]) number of nodes with both children.
Instance Method Summary collapse
-
#initialize ⇒ NodeStats
constructor
A new instance of NodeStats.
Constructor Details
#initialize ⇒ NodeStats
Returns a new instance of NodeStats.
46 47 48 49 50 51 52 53 54 |
# File 'lib/classbench/trie.rb', line 46 def initialize preinitialized_hash = Hash[*(0..DEFAULT_DEPTH).flat_map { |k, v| [k , 0] }] self.leaf = preinitialized_hash.dup; self.one_child = preinitialized_hash.dup; self.two_children = preinitialized_hash.dup; self.prefix = preinitialized_hash.dup; self.non_prefix = preinitialized_hash.dup; end |
Instance Attribute Details
#leaf ⇒ Object
(int[]) number of leaf nodes
40 41 42 |
# File 'lib/classbench/trie.rb', line 40 def leaf @leaf end |
#non_prefix ⇒ Object
(int[]) number of non-prefix nodes
44 45 46 |
# File 'lib/classbench/trie.rb', line 44 def non_prefix @non_prefix end |
#one_child ⇒ Object
(int[]) number of nodes with one child only
41 42 43 |
# File 'lib/classbench/trie.rb', line 41 def one_child @one_child end |
#prefix ⇒ Object
(int[]) number of prefix nodes (not prefixes)
43 44 45 |
# File 'lib/classbench/trie.rb', line 43 def prefix @prefix end |
#two_children ⇒ Object
(int[]) number of nodes with both children
42 43 44 |
# File 'lib/classbench/trie.rb', line 42 def two_children @two_children end |