Changeset 9031:26ed9a9441db in orange


Ignore:
Timestamp:
09/27/11 15:16:55 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
a619112fae539304d5b2c64c748bb537775ff15d
Message:

Inlined m_element comparison methods. Using a better m_element hash function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/hclust.cpp

    r9026 r9031  
    568568    m_element(const m_element & other); 
    569569 
    570     bool operator< (const m_element & other) const; 
    571     bool operator== (const m_element & other) const; 
     570    inline bool operator< (const m_element & other) const; 
     571    inline bool operator== (const m_element & other) const; 
    572572}; // cluster joined at left and right index 
    573573 
     
    618618struct m_element_hash 
    619619{ 
    620     size_t operator()(const m_element & m) const 
     620    inline size_t operator()(const m_element & m) const 
    621621    { 
    622         return ((size_t) m.cluster) * m.left * (m.right << 16); 
     622        size_t seed = 0; 
     623        hash_combine(seed, (size_t &) m.cluster); 
     624        hash_combine(seed, (size_t &) m.left); 
     625        hash_combine(seed, (size_t &) m.right); 
     626        return seed; 
     627    } 
     628 
     629    // more or less taken from boost::hash_combine 
     630    inline void hash_combine(size_t &seed, size_t &val) const 
     631    { 
     632        seed ^= val + 0x9e3779b9 + (seed << 6) + (seed >> 2); 
    623633    } 
    624634}; 
     
    744754                    mapping.begin() + right_left.last); 
    745755 
     756            // TODO: precompute the scores for m and k in an array and use a simpler 
     757            // comparison function 
    746758            std::sort(m_ordered.begin(), m_ordered.end(), CompareByScores(M, left, u)); 
    747759            std::sort(k_ordered.begin(), k_ordered.end(), CompareByScores(M, right, w)); 
Note: See TracChangeset for help on using the changeset viewer.