5 namespace type = utakata::type;
8 type::Type::Type(const std::string& str) : hash_(0), hash_string_(str) {
13 type::Type::Type(const type::Type& t) : hash_(t.hash_),
14 hash_string_(t.hash_string_) {}
17 type::Type& type::Type::operator=(const type::Type& p) {
23 // ここでのハッシュ値は、次のようなアルゴリズムで生成されます。
24 // 渡された文字列 s のn文字目の文字をSnと表したとき、
25 // hash = (S1 + !(S1 << 4)) + (S2 + !(S2 << 4))...(Sn + !(Sn << 4))
27 void type::Type::MakeHash() {
28 std::string::const_iterator beg = hash_string_.begin(),
29 end = hash_string_.end();
31 for (; beg != end; ++beg) {
32 // 各文字毎に簡単なハッシュ値を算出する。
33 hash_ += (*beg + (!(*beg << 4)));
38 void type::Type::Swap(type::Type& type) {
39 std::swap(hash_, type.hash_);
40 std::swap(hash_string_, type.hash_string_);