summaryrefslogtreecommitdiff
path: root/training/ttables.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-06-18 20:28:42 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-06-18 20:28:42 -0400
commitb89a1d3cb72ac36c137d6ae342f48ab9b8ee6655 (patch)
tree74dbff7519a3f3fe6906fff44128563300fec19b /training/ttables.h
parent953ec50e659084c13433ea311f6a07e7e1b292f8 (diff)
add non-const iterators to sparse vector, speed up model1 code
Diffstat (limited to 'training/ttables.h')
-rw-r--r--training/ttables.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/training/ttables.h b/training/ttables.h
index bf3351d2..9baa13ca 100644
--- a/training/ttables.h
+++ b/training/ttables.h
@@ -4,6 +4,7 @@
#include <iostream>
#include <tr1/unordered_map>
+#include "sparse_vector.h"
#include "m.h"
#include "wordid.h"
#include "tdict.h"
@@ -68,18 +69,18 @@ class TTable {
}
return *this;
}
- void ShowTTable() {
- for (Word2Word2Double::iterator it = ttable.begin(); it != ttable.end(); ++it) {
- Word2Double& cpd = it->second;
- for (Word2Double::iterator j = cpd.begin(); j != cpd.end(); ++j) {
+ void ShowTTable() const {
+ for (Word2Word2Double::const_iterator it = ttable.begin(); it != ttable.end(); ++it) {
+ const Word2Double& cpd = it->second;
+ for (Word2Double::const_iterator j = cpd.begin(); j != cpd.end(); ++j) {
std::cerr << "P(" << TD::Convert(j->first) << '|' << TD::Convert(it->first) << ") = " << j->second << std::endl;
}
}
}
- void ShowCounts() {
- for (Word2Word2Double::iterator it = counts.begin(); it != counts.end(); ++it) {
- Word2Double& cpd = it->second;
- for (Word2Double::iterator j = cpd.begin(); j != cpd.end(); ++j) {
+ void ShowCounts() const {
+ for (Word2Word2Double::const_iterator it = counts.begin(); it != counts.end(); ++it) {
+ const Word2Double& cpd = it->second;
+ for (Word2Double::const_iterator j = cpd.begin(); j != cpd.end(); ++j) {
std::cerr << "c(" << TD::Convert(j->first) << '|' << TD::Convert(it->first) << ") = " << j->second << std::endl;
}
}