Class: Classbench::NodeStats

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeNodeStats

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

#leafObject

(int[]) number of leaf nodes



40
41
42
# File 'lib/classbench/trie.rb', line 40

def leaf
  @leaf
end

#non_prefixObject

(int[]) number of non-prefix nodes



44
45
46
# File 'lib/classbench/trie.rb', line 44

def non_prefix
  @non_prefix
end

#one_childObject

(int[]) number of nodes with one child only



41
42
43
# File 'lib/classbench/trie.rb', line 41

def one_child
  @one_child
end

#prefixObject

(int[]) number of prefix nodes (not prefixes)



43
44
45
# File 'lib/classbench/trie.rb', line 43

def prefix
  @prefix
end

#two_childrenObject

(int[]) number of nodes with both children



42
43
44
# File 'lib/classbench/trie.rb', line 42

def two_children
  @two_children
end