summaryrefslogtreecommitdiff
path: root/tools/thirdparty/OpenFst/fst
diff options
context:
space:
mode:
Diffstat (limited to 'tools/thirdparty/OpenFst/fst')
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/Android.mk2
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/arcsort.h4
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/compat.h19
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/compose.h11
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/determinize.h16
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/encode.h11
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/epsnormalize.h6
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/equivalent.h5
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/factor-weight.h8
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/map.h2
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/minimize.h2
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/partition.h2
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/queue.h3
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/register.h4
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/relabel.h17
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/replace.h9
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/rmepsilon.h12
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/rmfinalepsilon.h5
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/symbol-table.cpp4
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/symbol-table.h13
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/synchronize.h8
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/test-properties.h14
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/vector-fst.h4
-rw-r--r--tools/thirdparty/OpenFst/fst/lib/weight.h2
24 files changed, 75 insertions, 108 deletions
diff --git a/tools/thirdparty/OpenFst/fst/lib/Android.mk b/tools/thirdparty/OpenFst/fst/lib/Android.mk
index 0593078..6e89e3c 100644
--- a/tools/thirdparty/OpenFst/fst/lib/Android.mk
+++ b/tools/thirdparty/OpenFst/fst/lib/Android.mk
@@ -16,6 +16,8 @@ LOCAL_C_INCLUDES := \
LOCAL_CFLAGS += \
-DFST_DL \
+LOCAL_CPPFLAGS += -std=c++11
+
LOCAL_SHARED_LIBRARIES := \
LOCAL_LDLIBS += -lpthread
diff --git a/tools/thirdparty/OpenFst/fst/lib/arcsort.h b/tools/thirdparty/OpenFst/fst/lib/arcsort.h
index 4d15adb..1486e50 100644
--- a/tools/thirdparty/OpenFst/fst/lib/arcsort.h
+++ b/tools/thirdparty/OpenFst/fst/lib/arcsort.h
@@ -283,7 +283,7 @@ template<class A> class ILabelCompare {
}
uint64 Properties(uint64 props) const {
- return props & kArcSortProperties | kILabelSorted;
+ return (props & kArcSortProperties) | kILabelSorted;
}
};
@@ -296,7 +296,7 @@ template<class A> class OLabelCompare {
}
uint64 Properties(uint64 props) const {
- return props & kArcSortProperties | kOLabelSorted;
+ return (props & kArcSortProperties) | kOLabelSorted;
}
};
diff --git a/tools/thirdparty/OpenFst/fst/lib/compat.h b/tools/thirdparty/OpenFst/fst/lib/compat.h
index 4c27ee3..cd80e2a 100644
--- a/tools/thirdparty/OpenFst/fst/lib/compat.h
+++ b/tools/thirdparty/OpenFst/fst/lib/compat.h
@@ -27,9 +27,9 @@
#include <string>
#include <vector>
-#include <ext/hash_map>
#include <fcntl.h>
#include <pthread.h>
+#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@@ -294,21 +294,4 @@ class MD5 {
DISALLOW_EVIL_CONSTRUCTORS(MD5);
};
-// Hashing functions
-namespace __gnu_cxx {
-
-template<> struct hash<int64> {
- size_t operator()(int64 x) const {
- return x;
- }
-};
-
-template<> struct hash<string> {
- size_t operator()(const string &s) const {
- return __stl_hash_string(s.c_str());
- }
-};
-
-} // namespace __gnu_cxx
-
#endif // FST_COMPAT_H__
diff --git a/tools/thirdparty/OpenFst/fst/lib/compose.h b/tools/thirdparty/OpenFst/fst/lib/compose.h
index 0783ea5..281e2af 100644
--- a/tools/thirdparty/OpenFst/fst/lib/compose.h
+++ b/tools/thirdparty/OpenFst/fst/lib/compose.h
@@ -21,8 +21,7 @@
#include <algorithm>
-#include <ext/hash_map>
-using __gnu_cxx::hash_map;
+#include <unordered_map>
#include "fst/lib/cache.h"
#include "fst/lib/test-properties.h"
@@ -252,10 +251,8 @@ class ComposeStateTable {
};
// Lookup table mapping state tuples to state IDs.
- typedef hash_map<StateTuple,
- StateId,
- StateTupleKey,
- StateTupleEqual> StateTable;
+ typedef std::unordered_map<StateTuple, StateId, StateTupleKey,
+ StateTupleEqual> StateTable;
// Actual table data.
StateTable table_;
@@ -369,7 +366,7 @@ class ComposeFstImpl : public ComposeFstImplBase<A> {
<< "sorted (special symbols present)";
break;
case 0:
- if (!isorted && !osorted || FLAGS_fst_verify_properties) {
+ if ((!isorted && !osorted) || FLAGS_fst_verify_properties) {
osorted = fst1.Properties(kOLabelSorted, true);
if (!osorted)
isorted = fst2.Properties(kILabelSorted, true);
diff --git a/tools/thirdparty/OpenFst/fst/lib/determinize.h b/tools/thirdparty/OpenFst/fst/lib/determinize.h
index fa0bb3c..d18451b 100644
--- a/tools/thirdparty/OpenFst/fst/lib/determinize.h
+++ b/tools/thirdparty/OpenFst/fst/lib/determinize.h
@@ -23,10 +23,8 @@
#include <algorithm>
#include <map>
-#include <ext/hash_map>
-using __gnu_cxx::hash_map;
-#include <ext/slist>
-using __gnu_cxx::slist;
+#include <unordered_map>
+#include <forward_list>
#include "fst/lib/cache.h"
#include "fst/lib/factor-weight.h"
@@ -218,7 +216,7 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<A> {
StateId state_id; // Input state Id
Weight weight; // Residual weight
};
- typedef slist<Element> Subset;
+ typedef std::forward_list<Element> Subset;
typedef map<Label, Subset*> LabelMap;
DeterminizeFsaImpl(const Fst<A> &fst, C common_divisor,
@@ -386,8 +384,10 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<A> {
// returns, elements_ will preserve that property. We keep it
// full of NULLs so that it is ready for the next call.
bool operator()(Subset* subset1, Subset* subset2) const {
- if (subset1->size() != subset2->size())
- return false;
+ size_t subset1_size = std::distance(subset1->begin(), subset1->end());
+ size_t subset2_size = std::distance(subset2->begin(), subset2->end());
+ if (subset1_size != subset2_size)
+ return false;
// Loads first subset elements in element vector.
for (typename Subset::iterator iter1 = subset1->begin();
@@ -454,7 +454,7 @@ class DeterminizeFsaImpl : public DeterminizeFstImplBase<A> {
vector<Subset *> subsets_;
// Hashes from Subset to its StateId in the output automaton.
- typedef hash_map<Subset *, StateId, SubsetKey, SubsetEqual>
+ typedef std::unordered_map<Subset *, StateId, SubsetKey, SubsetEqual>
SubsetHash;
// Hashes from Label to Subsets corr. to destination states of current state.
diff --git a/tools/thirdparty/OpenFst/fst/lib/encode.h b/tools/thirdparty/OpenFst/fst/lib/encode.h
index 882cdd0..b577d4a 100644
--- a/tools/thirdparty/OpenFst/fst/lib/encode.h
+++ b/tools/thirdparty/OpenFst/fst/lib/encode.h
@@ -93,10 +93,7 @@ template <class A> class EncodeTable {
int32 encode_flags_;
};
- typedef hash_map<const Tuple*,
- Label,
- TupleKey,
- TupleEqual> EncodeHash;
+ typedef std::unordered_map<const Tuple*, Label, TupleKey, TupleEqual> EncodeHash;
explicit EncodeTable(uint32 encode_flags)
: flags_(encode_flags),
@@ -174,7 +171,7 @@ template <class A> class EncodeTable {
return strm;
}
- const uint32 flags() const { return flags_; }
+ uint32 flags() const { return flags_; }
private:
uint32 flags_;
vector<Tuple*> encode_tuples_;
@@ -271,8 +268,8 @@ template <class A> class EncodeMapper {
MAP_REQUIRE_SUPERFINAL : MAP_NO_SUPERFINAL;
}
- const uint32 flags() const { return flags_; }
- const EncodeType type() const { return type_; }
+ uint32 flags() const { return flags_; }
+ EncodeType type() const { return type_; }
bool Write(ostream &strm, const string& source) {
return table_->Write(strm, source);
diff --git a/tools/thirdparty/OpenFst/fst/lib/epsnormalize.h b/tools/thirdparty/OpenFst/fst/lib/epsnormalize.h
index ac4baf2..e040977 100644
--- a/tools/thirdparty/OpenFst/fst/lib/epsnormalize.h
+++ b/tools/thirdparty/OpenFst/fst/lib/epsnormalize.h
@@ -20,10 +20,8 @@
#ifndef FST_LIB_EPSNORMALIZE_H__
#define FST_LIB_EPSNORMALIZE_H__
-#include <ext/hash_map>
-using __gnu_cxx::hash_map;
-#include <ext/slist>
-using __gnu_cxx::slist;
+#include <unordered_map>
+#include <forward_list>
#include "fst/lib/factor-weight.h"
#include "fst/lib/invert.h"
diff --git a/tools/thirdparty/OpenFst/fst/lib/equivalent.h b/tools/thirdparty/OpenFst/fst/lib/equivalent.h
index e585d9b..cb648aa 100644
--- a/tools/thirdparty/OpenFst/fst/lib/equivalent.h
+++ b/tools/thirdparty/OpenFst/fst/lib/equivalent.h
@@ -21,8 +21,7 @@
#include <algorithm>
-#include <ext/hash_map>
-using __gnu_cxx::hash_map;
+#include <unordered_map>
#include "fst/lib/encode.h"
#include "fst/lib/push.h"
@@ -162,7 +161,7 @@ bool Equivalent(const Fst<Arc> &fst1, const Fst<Arc> &fst2) {
// representing destination states of the corresponding arcs in fst1
// and fst2, respectively.
typedef
- hash_map<typename Arc::Label, pair<MappedId, MappedId> >
+ std::unordered_map<typename Arc::Label, pair<MappedId, MappedId> >
Label2StatePairMap;
Label2StatePairMap arc_pairs;
diff --git a/tools/thirdparty/OpenFst/fst/lib/factor-weight.h b/tools/thirdparty/OpenFst/fst/lib/factor-weight.h
index 073a476..f1bd950 100644
--- a/tools/thirdparty/OpenFst/fst/lib/factor-weight.h
+++ b/tools/thirdparty/OpenFst/fst/lib/factor-weight.h
@@ -22,10 +22,8 @@
#include <algorithm>
-#include <ext/hash_map>
-using __gnu_cxx::hash_map;
-#include <ext/slist>
-using __gnu_cxx::slist;
+#include <unordered_map>
+#include <forward_list>
#include "fst/lib/cache.h"
#include "fst/lib/test-properties.h"
@@ -310,7 +308,7 @@ class FactorWeightFstImpl
static const int kPrime = 7853;
};
- typedef hash_map<Element, StateId, ElementKey, ElementEqual> ElementMap;
+ typedef std::unordered_map<Element, StateId, ElementKey, ElementEqual> ElementMap;
const Fst<A> *fst_;
float delta_;
diff --git a/tools/thirdparty/OpenFst/fst/lib/map.h b/tools/thirdparty/OpenFst/fst/lib/map.h
index 5d56ebe..afcc25d 100644
--- a/tools/thirdparty/OpenFst/fst/lib/map.h
+++ b/tools/thirdparty/OpenFst/fst/lib/map.h
@@ -835,7 +835,7 @@ struct GallicToNewSymbolsMapper {
}
};
- typedef hash_map<SW, Label, StringKey> Map;
+ typedef std::unordered_map<SW, Label, StringKey> Map;
MutableFst<ToArc> *fst_;
Map map_;
diff --git a/tools/thirdparty/OpenFst/fst/lib/minimize.h b/tools/thirdparty/OpenFst/fst/lib/minimize.h
index 4a2aa38..da481ca 100644
--- a/tools/thirdparty/OpenFst/fst/lib/minimize.h
+++ b/tools/thirdparty/OpenFst/fst/lib/minimize.h
@@ -365,7 +365,7 @@ class AcyclicMinimizer {
const vector<StateId>& height() const { return height_; }
- const size_t num_states() const { return num_states_; }
+ size_t num_states() const { return num_states_; }
private:
vector<StateId> height_;
diff --git a/tools/thirdparty/OpenFst/fst/lib/partition.h b/tools/thirdparty/OpenFst/fst/lib/partition.h
index 1a3f5cd..2b6db6b 100644
--- a/tools/thirdparty/OpenFst/fst/lib/partition.h
+++ b/tools/thirdparty/OpenFst/fst/lib/partition.h
@@ -212,7 +212,7 @@ class Partition {
return class_size_;
}
- const size_t class_size(T class_id) const {
+ size_t class_size(T class_id) const {
return class_size_[class_id];
}
diff --git a/tools/thirdparty/OpenFst/fst/lib/queue.h b/tools/thirdparty/OpenFst/fst/lib/queue.h
index 478dfa7..1967165 100644
--- a/tools/thirdparty/OpenFst/fst/lib/queue.h
+++ b/tools/thirdparty/OpenFst/fst/lib/queue.h
@@ -669,12 +669,13 @@ void AutoQueue<StateId>::SccQueueType(const Fst<A> &fst,
QueueType &type = (*queue_type)[scc[state]];
if (!less || ((*less)(arc.weight, Weight::One())))
type = FIFO_QUEUE;
- else if ((type == TRIVIAL_QUEUE) || (type == LIFO_QUEUE))
+ else if ((type == TRIVIAL_QUEUE) || (type == LIFO_QUEUE)) {
if (!(Weight::Properties() & kIdempotent) ||
(arc.weight != Weight::Zero() && arc.weight != Weight::One()))
type = SHORTEST_FIRST_QUEUE;
else
type = LIFO_QUEUE;
+ }
if (type != TRIVIAL_QUEUE) *all_trivial = false;
}
if (!(Weight::Properties() & kIdempotent) ||
diff --git a/tools/thirdparty/OpenFst/fst/lib/register.h b/tools/thirdparty/OpenFst/fst/lib/register.h
index d15f28f..172799d 100644
--- a/tools/thirdparty/OpenFst/fst/lib/register.h
+++ b/tools/thirdparty/OpenFst/fst/lib/register.h
@@ -55,11 +55,11 @@ class FstRegister {
return register_;
}
- const Reader GetReader(const string &type) const {
+ Reader GetReader(const string &type) const {
return GetEntry(type).reader;
}
- const Converter GetConverter(const string &type) const {
+ Converter GetConverter(const string &type) const {
return GetEntry(type).converter;
}
diff --git a/tools/thirdparty/OpenFst/fst/lib/relabel.h b/tools/thirdparty/OpenFst/fst/lib/relabel.h
index d7f5185..2c32e77 100644
--- a/tools/thirdparty/OpenFst/fst/lib/relabel.h
+++ b/tools/thirdparty/OpenFst/fst/lib/relabel.h
@@ -19,8 +19,7 @@
#ifndef FST_LIB_RELABEL_H__
#define FST_LIB_RELABEL_H__
-#include <ext/hash_map>
-using __gnu_cxx::hash_map;
+#include <unordered_map>
#include "fst/lib/cache.h"
#include "fst/lib/test-properties.h"
@@ -49,12 +48,12 @@ void Relabel(
uint64 props = fst->Properties(kFstProperties, false);
// construct label to label hash. Could
- hash_map<Label, Label> input_map;
+ std::unordered_map<Label, Label> input_map;
for (size_t i = 0; i < ipairs.size(); ++i) {
input_map[ipairs[i].first] = ipairs[i].second;
}
- hash_map<Label, Label> output_map;
+ std::unordered_map<Label, Label> output_map;
for (size_t i = 0; i < opairs.size(); ++i) {
output_map[opairs[i].first] = opairs[i].second;
}
@@ -68,7 +67,7 @@ void Relabel(
// relabel input
// only relabel if relabel pair defined
- typename hash_map<Label, Label>::iterator it =
+ typename std::unordered_map<Label, Label>::iterator it =
input_map.find(arc.ilabel);
if (it != input_map.end()) {arc.ilabel = it->second; }
@@ -277,14 +276,14 @@ class RelabelFstImpl : public CacheImpl<A> {
// relabel input
if (relabel_input_) {
- typename hash_map<Label, Label>::iterator it =
+ typename std::unordered_map<Label, Label>::iterator it =
input_map_.find(arc.ilabel);
if (it != input_map_.end()) { arc.ilabel = it->second; }
}
// relabel output
if (relabel_output_) {
- typename hash_map<Label, Label>::iterator it =
+ typename std::unordered_map<Label, Label>::iterator it =
output_map_.find(arc.olabel);
if (it != output_map_.end()) { arc.olabel = it->second; }
}
@@ -298,8 +297,8 @@ class RelabelFstImpl : public CacheImpl<A> {
private:
const Fst<A> *fst_;
- hash_map<Label, Label> input_map_;
- hash_map<Label, Label> output_map_;
+ std::unordered_map<Label, Label> input_map_;
+ std::unordered_map<Label, Label> output_map_;
bool relabel_input_;
bool relabel_output_;
diff --git a/tools/thirdparty/OpenFst/fst/lib/replace.h b/tools/thirdparty/OpenFst/fst/lib/replace.h
index 4b8622e..2c7d1f7 100644
--- a/tools/thirdparty/OpenFst/fst/lib/replace.h
+++ b/tools/thirdparty/OpenFst/fst/lib/replace.h
@@ -20,8 +20,7 @@
#ifndef FST_LIB_REPLACE_H__
#define FST_LIB_REPLACE_H__
-#include <ext/hash_map>
-using __gnu_cxx::hash_map;
+#include <unordered_map>
#include "fst/lib/fst.h"
#include "fst/lib/cache.h"
@@ -75,7 +74,7 @@ class ReplaceFstImpl : public CacheImpl<A> {
typedef typename A::StateId StateId;
typedef CacheState<A> State;
typedef A Arc;
- typedef hash_map<Label, Label> NonTerminalHash;
+ typedef std::unordered_map<Label, Label> NonTerminalHash;
// \struct StateTuple
@@ -379,7 +378,7 @@ class ReplaceFstImpl : public CacheImpl<A> {
}
};
- typedef hash_map<StateTuple, StateId, StateTupleKey, StateTupleEqual>
+ typedef std::unordered_map<StateTuple, StateId, StateTupleKey, StateTupleEqual>
StateTupleHash;
// \class PrefixTuple
@@ -451,7 +450,7 @@ class ReplaceFstImpl : public CacheImpl<A> {
}
};
- typedef hash_map<StackPrefix, int, StackPrefixKey, StackPrefixEqual>
+ typedef std::unordered_map<StackPrefix, int, StackPrefixKey, StackPrefixEqual>
StackPrefixHash;
// private methods
diff --git a/tools/thirdparty/OpenFst/fst/lib/rmepsilon.h b/tools/thirdparty/OpenFst/fst/lib/rmepsilon.h
index 69a641b..107ae07 100644
--- a/tools/thirdparty/OpenFst/fst/lib/rmepsilon.h
+++ b/tools/thirdparty/OpenFst/fst/lib/rmepsilon.h
@@ -20,10 +20,8 @@
#ifndef FST_LIB_RMEPSILON_H__
#define FST_LIB_RMEPSILON_H__
-#include <ext/hash_map>
-using __gnu_cxx::hash_map;
-#include <ext/slist>
-using __gnu_cxx::slist;
+#include <unordered_map>
+#include <forward_list>
#include "fst/lib/arcfilter.h"
#include "fst/lib/cache.h"
@@ -109,8 +107,8 @@ class RmEpsilonState {
};
private:
- typedef hash_map<Element, pair<StateId, ssize_t>,
- ElementKey, ElementEqual> ElementMap;
+ typedef std::unordered_map<Element, pair<StateId, ssize_t>,
+ ElementKey, ElementEqual> ElementMap;
const Fst<Arc> &fst_;
// Distance from state being expanded in epsilon-closure.
@@ -125,7 +123,7 @@ class RmEpsilonState {
EpsilonArcFilter<Arc> eps_filter_;
stack<StateId> eps_queue_; // Queue used to visit the epsilon-closure
vector<bool> visited_; // '[i] = true' if state 'i' has been visited
- slist<StateId> visited_states_; // List of visited states
+ std::forward_list<StateId> visited_states_; // List of visited states
vector<Arc> arcs_; // Arcs of state being expanded
Weight final_; // Final weight of state being expanded
diff --git a/tools/thirdparty/OpenFst/fst/lib/rmfinalepsilon.h b/tools/thirdparty/OpenFst/fst/lib/rmfinalepsilon.h
index 900f0bb..acf3f35 100644
--- a/tools/thirdparty/OpenFst/fst/lib/rmfinalepsilon.h
+++ b/tools/thirdparty/OpenFst/fst/lib/rmfinalepsilon.h
@@ -19,8 +19,7 @@
#ifndef FST_LIB_RMFINALEPSILON_H__
#define FST_LIB_RMFINALEPSILON_H__
-#include <ext/hash_set>
-using __gnu_cxx::hash_set;
+#include <unordered_set>
#include "fst/lib/connect.h"
#include "fst/lib/mutable-fst.h"
@@ -42,7 +41,7 @@ void RmFinalEpsilon(MutableFst<A>* fst) {
// Find potential list of removable final states. These are final states
// that have no outgoing transitions or final states that have a
// non-coaccessible future. Complexity O(S)
- hash_set<StateId> finals;
+ std::unordered_set<StateId> finals;
for (StateIterator<Fst<A> > siter(*fst); !siter.Done(); siter.Next()) {
StateId s = siter.Value();
if (fst->Final(s) != Weight::Zero()) {
diff --git a/tools/thirdparty/OpenFst/fst/lib/symbol-table.cpp b/tools/thirdparty/OpenFst/fst/lib/symbol-table.cpp
index 74c2dad..d4715da 100644
--- a/tools/thirdparty/OpenFst/fst/lib/symbol-table.cpp
+++ b/tools/thirdparty/OpenFst/fst/lib/symbol-table.cpp
@@ -80,7 +80,7 @@ void SymbolTableImpl::RecomputeCheckSum() const {
}
int64 SymbolTableImpl::AddSymbol(const string& symbol, int64 key) {
- hash_map<string, int64>::const_iterator it =
+ std::unordered_map<string, int64>::const_iterator it =
symbol_map_.find(symbol);
if (it == symbol_map_.end()) { // only add if not in table
check_sum_finalized_ = false;
@@ -134,7 +134,7 @@ bool SymbolTableImpl::Write(ostream &strm) const {
for (size_t i = 0; i < symbols_.size(); ++i) {
const string symbol = symbols_[i];
WriteType(strm, symbol);
- hash_map<string, int64>::const_iterator it = symbol_map_.find(symbol);
+ std::unordered_map<string, int64>::const_iterator it = symbol_map_.find(symbol);
WriteType(strm, it->second);
}
strm.flush();
diff --git a/tools/thirdparty/OpenFst/fst/lib/symbol-table.h b/tools/thirdparty/OpenFst/fst/lib/symbol-table.h
index 0a67f29..50b3bd1 100644
--- a/tools/thirdparty/OpenFst/fst/lib/symbol-table.h
+++ b/tools/thirdparty/OpenFst/fst/lib/symbol-table.h
@@ -19,11 +19,10 @@
#ifndef FST_LIB_SYMBOL_TABLE_H__
#define FST_LIB_SYMBOL_TABLE_H__
-#include <ext/hash_map>
-using __gnu_cxx::hash_map;
#include <fstream>
#include <iostream>
#include <string>
+#include <unordered_map>
#include <vector>
#include "fst/lib/compat.h"
@@ -70,7 +69,7 @@ class SymbolTableImpl {
// Return the string associated with the key. If the key is out of
// range (<0, >max), return an empty string.
string Find(int64 key) const {
- hash_map<int64, string>::const_iterator it =
+ std::unordered_map<int64, string>::const_iterator it =
key_map_.find(key);
if (it == key_map_.end()) {
return "";
@@ -89,7 +88,7 @@ class SymbolTableImpl {
// Return the key associated with the symbol. If the symbol
// does not exists, return -1.
int64 Find(const char* symbol) const {
- hash_map<string, int64>::const_iterator it =
+ unordered_map<string, int64>::const_iterator it =
symbol_map_.find(symbol);
if (it == symbol_map_.end()) {
return -1;
@@ -126,8 +125,8 @@ class SymbolTableImpl {
string name_;
int64 available_key_;
vector<const char *> symbols_;
- hash_map<int64, string> key_map_;
- hash_map<string, int64> symbol_map_;
+ std::unordered_map<int64, string> key_map_;
+ std::unordered_map<string, int64> symbol_map_;
mutable int ref_count_;
mutable bool check_sum_finalized_;
@@ -376,7 +375,7 @@ inline bool CompatSymbols(const SymbolTable *syms1,
return true;
else if (!syms1 && !syms2)
return true;
- else if (syms1 && !syms2 || !syms1 && syms2)
+ else if ((syms1 && !syms2) || (!syms1 && syms2))
return false;
else
return syms1->CheckSum() == syms2->CheckSum();
diff --git a/tools/thirdparty/OpenFst/fst/lib/synchronize.h b/tools/thirdparty/OpenFst/fst/lib/synchronize.h
index cf416d6..aff1e5e 100644
--- a/tools/thirdparty/OpenFst/fst/lib/synchronize.h
+++ b/tools/thirdparty/OpenFst/fst/lib/synchronize.h
@@ -22,8 +22,8 @@
#include <algorithm>
-#include <ext/hash_map>
-using __gnu_cxx::hash_map;
+#include <unordered_map>
+#include <unordered_set>
#include "fst/lib/cache.h"
#include "fst/lib/test-properties.h"
@@ -287,8 +287,8 @@ class SynchronizeFstImpl
};
- typedef hash_map<Element, StateId, ElementKey, ElementEqual> ElementMap;
- typedef hash_set<const String*, StringKey, StringEqual> StringSet;
+ typedef std::unordered_map<Element, StateId, ElementKey, ElementEqual> ElementMap;
+ typedef std::unordered_set<const String*, StringKey, StringEqual> StringSet;
const Fst<A> *fst_;
vector<Element> elements_; // mapping Fst state to Elements
diff --git a/tools/thirdparty/OpenFst/fst/lib/test-properties.h b/tools/thirdparty/OpenFst/fst/lib/test-properties.h
index b167e0a..f4710c0 100644
--- a/tools/thirdparty/OpenFst/fst/lib/test-properties.h
+++ b/tools/thirdparty/OpenFst/fst/lib/test-properties.h
@@ -19,9 +19,7 @@
#ifndef FST_LIB_TEST_PROPERTIES_H__
#define FST_LIB_TEST_PROPERTIES_H__
-#include <ext/hash_set>
-using __gnu_cxx::hash_set;
-
+#include <unordered_set>
#include "fst/lib/connect.h"
#include "fst/lib/dfs-visit.h"
@@ -35,7 +33,7 @@ namespace fst {
// For a trinary (i.e. two-bit) property, both bits are
// returned set iff either corresponding input bit is set.
inline uint64 KnownProperties(uint64 props) {
- return kBinaryProperties | props & kTrinaryProperties |
+ return kBinaryProperties | (props & kTrinaryProperties) |
(props & kPosTrinaryProperties) << 1 |
(props & kNegTrinaryProperties) >> 1;
}
@@ -114,8 +112,8 @@ uint64 ComputeProperties(const Fst<Arc> &fst, uint64 mask, uint64 *known,
if (mask & (kODeterministic | kNonODeterministic))
comp_props |= kODeterministic;
- hash_set<Label> *ilabels = 0;
- hash_set<Label> *olabels = 0;
+ std::unordered_set<Label> *ilabels = 0;
+ std::unordered_set<Label> *olabels = 0;
StateId nfinal = 0;
for (StateIterator< Fst<Arc> > siter(fst);
@@ -126,9 +124,9 @@ uint64 ComputeProperties(const Fst<Arc> &fst, uint64 mask, uint64 *known,
Arc prev_arc(kNoLabel, kNoLabel, Weight::One(), 0);
// Create these only if we need to
if (mask & (kIDeterministic | kNonIDeterministic))
- ilabels = new hash_set<Label>;
+ ilabels = new std::unordered_set<Label>;
if (mask & (kODeterministic | kNonODeterministic))
- olabels = new hash_set<Label>;
+ olabels = new std::unordered_set<Label>;
for (ArcIterator< Fst<Arc> > aiter(fst, s);
!aiter.Done();
diff --git a/tools/thirdparty/OpenFst/fst/lib/vector-fst.h b/tools/thirdparty/OpenFst/fst/lib/vector-fst.h
index 5950e6f..fde934a 100644
--- a/tools/thirdparty/OpenFst/fst/lib/vector-fst.h
+++ b/tools/thirdparty/OpenFst/fst/lib/vector-fst.h
@@ -360,7 +360,7 @@ VectorFstImpl<A> *VectorFstImpl<A>::Read(istream &strm,
impl->BaseImpl::AddState();
VectorState<A> *state = impl->GetState(s);
state->final.Read(strm);
- int64 narcs;
+ uint64 narcs;
ReadType(strm, &narcs);
if (!strm) {
LOG(ERROR) << "VectorFst::Read: read failed: " << opts.source;
@@ -429,7 +429,7 @@ bool VectorFstImpl<A>::Write(ostream &strm,
for (StateId s = 0; s < NumStates(); ++s) {
const VectorState<A> *state = this->GetState(s);
state->final.Write(strm);
- int64 narcs = state->arcs.size();
+ size_t narcs = state->arcs.size();
WriteType(strm, narcs);
for (size_t a = 0; a < narcs; ++a) {
const A &arc = state->arcs[a];
diff --git a/tools/thirdparty/OpenFst/fst/lib/weight.h b/tools/thirdparty/OpenFst/fst/lib/weight.h
index 7050f50..06c2b9e 100644
--- a/tools/thirdparty/OpenFst/fst/lib/weight.h
+++ b/tools/thirdparty/OpenFst/fst/lib/weight.h
@@ -124,7 +124,7 @@ class NaturalLess {
NaturalLess() {
uint64 props = kIdempotent | kLeftSemiring | kRightSemiring;
- if (W::Properties() & props != props)
+ if ((W::Properties() & props) != props)
LOG(ERROR) << "NaturalLess: Weight type is not idempotent and "
<< "(left and right) distributive: " << W::Type();
}