Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mystl.h « mkcls-v2 - github.com/moses-smt/giza-pp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2d8f9caba78535f6b0859c2722cb72685ef904c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*

Copyright (C) 1997,1998,1999,2000,2001  Franz Josef Och

mkcls - a program for making word classes .

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
USA.

*/



#ifndef MY_STL_H_DEFINED
#define MY_STL_H_DEFINED
#include <string>
#include <utility>
#if __cplusplus < 201103L && !defined(_LIBCPP_VERSION)
#include <tr1/unordered_map>
#else
#include <unordered_map>
#endif
#include <cmath>

using namespace std;

namespace std {
#if __cplusplus < 201103L && !defined(_LIBCPP_VERSION)
 namespace tr1 {
#endif
  template <typename T, typename V>
  struct hash<pair<T, V> > {
    static inline void hash_combine(std::size_t & seed, const T & v) {
       hash<T> hasher;
       seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    }

    size_t operator()(const std::pair<T, V>& x) const {
      size_t h = 0;
      hash_combine(h, x.first);
      hash_combine(h, x.second);
      return h;
    }
  };
#if __cplusplus < 201103L && !defined(_LIBCPP_VERSION)
 }
#endif
}

#define over_string(a,i) for(unsigned int i=0;i<a.length();i++)

template<class T1,class T2>
istream& operator>>(istream &in,pair<T1,T2> &ir)
{
 char c;
 do in.get(c); while (in && isspace(c));
 if (!in) return in;
 if (c != '(') in.putback(c);
 in >> ir.first;
 do in.get(c); while (isspace(c));
 if (c != ',') in.putback(c);
 in >> ir.second; 
 do in.get(c); while (c == ' ');
 if (c != ')') in.putback(c);
 return in; 
}

template<class T1,class T2>
ostream& operator<<(ostream &out,const pair<T1,T2> &ir)
{ 
  out << "(" << ir.first << "," << ir.second << ")";
  return out;
} 

void printSpaces(ostream&out,int n);
void mysplit(const string &s,string &s1,string &s2);
string untilChar(const string&s,char c);

template<class A,class B,class C>
class tri
{
public:
  A a;
  B b;
  C c;
  tri(){};
  tri(const A&_a,const B&_b,const C&_c)
    : a(_a),b(_b),c(_c) {}
};
template<class A,class B,class C>
bool operator==(const tri<A,B,C>&x,const tri<A,B,C>&y)
{ return x.a==y.a&&x.b==y.b&&x.c==y.c;}

template<class A,class B,class C>
bool operator<(const tri<A,B,C>&x,const tri<A,B,C>&y)
{
  if(x.a<y.a)
    return 1;
  if(y.a<x.a)
    return 0;

  if(x.b<y.b)
    return 1;
  if(y.b<x.b)
    return 0;

  if(x.c<y.c)
    return 1;
  if(y.c<x.c)
    return 0;
  return 0;
}

#endif