Ignore:
Timestamp:
Sep 6, 2008, 10:44:58 PM (17 years ago)
Author:
[email protected]
Message:

Merge squirrelfish-extreme to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/HashTraits.h

    r35900 r36244  
    8282    };
    8383
    84     // default integer traits disallow both 0 and -1 as keys (max value instead of -1 for unsigned)
     84    // Default integer traits disallow both 0 and -1 as keys (max value instead of -1 for unsigned).
    8585    template<typename T> struct GenericHashTraitsBase<true, T> {
    8686        static const bool emptyValueIsZero = true;
     
    106106    template<> struct HashTraits<float> : FloatHashTraits<float> { };
    107107    template<> struct HashTraits<double> : FloatHashTraits<double> { };
     108
     109    // Default unsigned traits disallow both 0 and max as keys -- use these traits to allow zero and disallow max - 1.
     110    template<typename T> struct UnsignedWithZeroKeyHashTraits : GenericHashTraits<T> {
     111        static const bool emptyValueIsZero = false;
     112        static const bool needsDestruction = false;
     113        static T emptyValue() { return std::numeric_limits<T>::max(); }
     114        static void constructDeletedValue(T& slot) { slot = std::numeric_limits<T>::max() - 1; }
     115        static bool isDeletedValue(T value) { return value == std::numeric_limits<T>::max() - 1; }
     116    };
    108117
    109118    template<typename P> struct HashTraits<P*> : GenericHashTraits<P*> {
Note: See TracChangeset for help on using the changeset viewer.