<commit_before>// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NINJA_MAP_H_
#define NINJA_MAP_H_

#include <string.h>

#ifdef _MSC_VER
#include <hash_map>

using stdext::hash_map;

#else

#include <ext/hash_map>

using __gnu_cxx::hash_map;

namespace __gnu_cxx {
template<>
struct hash<std::string> {
  size_t operator()(const std::string& s) const {
    return hash<const char*>()(s.c_str());
  }
};
}

#endif

/// Equality binary predicate for const char*.
struct ExternalStringEq {
  bool operator()(const char* a, const char* b) {
    return strcmp(a, b) == 0;
  }
};

/// Hash functor for const char*.
struct ExternalStringHash {
  size_t operator()(const char* key) const {
#ifdef _MSC_VER
    return stdext::hash<const char*>()(key);
#else
    return __gnu_cxx::hash<const char*>()(key);
#endif
  }
};

/// A template for hash_maps keyed by a const char* that is maintained within
/// the values.  Use like:
///   ExternalStringHash<Foo*>::Type foos;
/// to make foos into a hash mapping const char* => Foo*.
template<typename V>
struct ExternalStringHashMap {
  typedef hash_map<const char*, V, ExternalStringHash, ExternalStringEq> Type;
};

#endif // NINJA_MAP_H_<commit_msg>Changes to hash_map to make it build with MSVC's version<commit_after>// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NINJA_MAP_H_
#define NINJA_MAP_H_

#include <string.h>

#ifdef _MSC_VER
#include <hash_map>

using stdext::hash_map;
using stdext::hash_compare;

struct ExternalStringCmp {
  bool operator()(const char* a, const char* b) const {
    return strcmp(a, b) < 0;
  }
};

#else

#include <ext/hash_map>

using __gnu_cxx::hash_map;

namespace __gnu_cxx {
template<>
struct hash<std::string> {
  size_t operator()(const std::string& s) const {
    return hash<const char*>()(s.c_str());
  }
};
}


/// Equality binary predicate for const char*.
struct ExternalStringEq {
  bool operator()(const char* a, const char* b) {
    return strcmp(a, b) == 0;
  }
};

/// Hash functor for const char*.
struct ExternalStringHash {
  size_t operator()(const char* key) const {
    return __gnu_cxx::hash<const char*>()(key);
  }
};
#endif

/// A template for hash_maps keyed by a const char* that is maintained within
/// the values.  Use like:
///   ExternalStringHash<Foo*>::Type foos;
/// to make foos into a hash mapping const char* => Foo*.
template<typename V>
struct ExternalStringHashMap {
#ifdef _MSC_VER
  typedef hash_map<const char*, V, hash_compare<const char *,ExternalStringCmp> > Type;
#else
  typedef hash_map<const char*, V, ExternalStringHash, ExternalStringEq> Type;
#endif
};

#endif // NINJA_MAP_H_
{'fraction_non_alphanumeric': 0.11778846153846154, 'fraction_numerical': 0.005074786324786325, 'mean_word_length': 3.993333333333333, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6366800', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1165, 'n_words': 429}