<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  uses('util.collections.MD5HashImplementation');

  /**
   * Provides hashing functionality for maps.
   * 
   * Basic usage:
   * <code>
   *   $hashCode= HashProvider::hashOf($string);
   * </code>
   *
   * Uses MD5 as default hashing implementation. To change the hashing
   * implementation to be used, use the following:
   * <code>
   *   HashProvider::getInstance()->setImplementation(new MyHashImplementation());
   * </code>
   * 
   * @see      xp://util.collections.DJBX33AHashImplementation
   * @see      xp://util.collections.MD5HashImplementation
   * @see      xp://util.collections.Map
   * @purpose  Hashing
   */
  class HashProvider extends Object {
    protected static
      $instance = NULL;

    public
      $impl     = NULL;

    static function __static() {
      self::$instance= new self();
      
      // Workaround for bugs in older PHP versions, see MD5HexHashImplementation's
      // class apidoc for an explanation. Earlier versions returned LONG_MAX for
      // hex numbers larger than LONG_MAX. Use 2^64 + 1 as hex literal and see if
      // it's "truncated", using the slower hexdec(md5()) implementation then.
      if (LONG_MAX === 0x20c49ba5e35423) {
        $impl= XPClass::forName('util.collections.MD5HexHashImplementation')->newInstance();
      } else {
        $impl= new MD5HashImplementation();
      }
      self::$instance->setImplementation($impl);
    }

    /**
     * Constructor
     *
     */
    protected function __construct() {
    }
    
    /**
     * Retrieve sole instance of this object
     *
     * @return  util.collections.HashProvider
     */
    public static function getInstance() {
      return self::$instance;
    }
    
    /**
     * Returns hash for a given string
     *
     * @param   string str
     * @return  int
     */<commit_msg>- Fix "Hex number is too big: 0x20c49ba5e35423" # Only occurs in broken PHP versions!<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  uses('util.collections.MD5HashImplementation');

  /**
   * Provides hashing functionality for maps.
   * 
   * Basic usage:
   * <code>
   *   $hashCode= HashProvider::hashOf($string);
   * </code>
   *
   * Uses MD5 as default hashing implementation. To change the hashing
   * implementation to be used, use the following:
   * <code>
   *   HashProvider::getInstance()->setImplementation(new MyHashImplementation());
   * </code>
   * 
   * @see      xp://util.collections.DJBX33AHashImplementation
   * @see      xp://util.collections.MD5HashImplementation
   * @see      xp://util.collections.Map
   * @purpose  Hashing
   */
  class HashProvider extends Object {
    protected static
      $instance = NULL;

    public
      $impl     = NULL;

    static function __static() {
      self::$instance= new self();
      
      // Workaround for bugs in older PHP versions, see MD5HexHashImplementation's
      // class apidoc for an explanation. Earlier versions returned LONG_MAX for
      // hex numbers larger than LONG_MAX. Use 2^64 + 1 as hex literal and see if
      // it's "truncated", using the slower hexdec(md5()) implementation then.
      if (LONG_MAX === @0x20c49ba5e35423) {
        $impl= XPClass::forName('util.collections.MD5HexHashImplementation')->newInstance();
      } else {
        $impl= new MD5HashImplementation();
      }
      self::$instance->setImplementation($impl);
    }

    /**
     * Constructor
     *
     */
    protected function __construct() {
    }
    
    /**
     * Retrieve sole instance of this object
     *
     * @return  util.collections.HashProvider
     */
    public static function getInstance() {
      return self::$instance;
    }
    
    /**
     * Returns hash for a given string
     *
     * @param   string str
     * @return  int
     */
{'fraction_non_alphanumeric': 0.11265790152101057, 'fraction_numerical': 0.015210105697344677, 'mean_word_length': 2.4275618374558303, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4257020', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1135, 'n_words': 309}