Commit 57617054 authored by darin's avatar darin

Reviewed by Anders.

        - changed deleteAllValues so it can work on "const" collections
          Deleting the values affects the values, not the pointers in the
          collection, so it's legitimate to do it to a const collection,
          and a case of that actually came up in the XPath code.

        * wtf/HashMap.h:
        (WTF::deleteAllPairSeconds): Use const iterators.
        (WTF::deleteAllValues): Take const HashMap reference as a parameter.
        * wtf/HashSet.h:
        (WTF::deleteAllValues): Take const HashSet reference as a parameter,
        and use const iterators.
        * wtf/Vector.h:
        (WTF::deleteAllValues): Take const Vector reference as a parameter.

        - added more functions that are present in <math.h> on some platforms,
          but not on others; moved here from various files in WebCore

        * wtf/MathExtras.h:
        (isinf): Added.
        (isnan): Added.
        (lround): Added.
        (lroundf): Tweaked.
        (round): Added.
        (roundf): Tweaked.
        (signbit): Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@14728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fb5e6eec
2006-06-04 Darin Adler <darin@apple.com>
Reviewed by Anders.
- changed deleteAllValues so it can work on "const" collections
Deleting the values affects the values, not the pointers in the
collection, so it's legitimate to do it to a const collection,
and a case of that actually came up in the XPath code.
* wtf/HashMap.h:
(WTF::deleteAllPairSeconds): Use const iterators.
(WTF::deleteAllValues): Take const HashMap reference as a parameter.
* wtf/HashSet.h:
(WTF::deleteAllValues): Take const HashSet reference as a parameter,
and use const iterators.
* wtf/Vector.h:
(WTF::deleteAllValues): Take const Vector reference as a parameter.
- added more functions that are present in <math.h> on some platforms,
but not on others; moved here from various files in WebCore
* wtf/MathExtras.h:
(isinf): Added.
(isnan): Added.
(lround): Added.
(lroundf): Tweaked.
(round): Added.
(roundf): Tweaked.
(signbit): Added.
2006-06-02 Mitz Pettel <opendarwin.org@mitzpettel.com>
Reviewed by ggaren.
......
......@@ -308,14 +308,14 @@ namespace WTF {
template<typename MappedType, typename HashTableType>
void deleteAllPairSeconds(HashTableType& collection)
{
typedef typename HashTableType::iterator iterator;
typedef typename HashTableType::const_iterator iterator;
iterator end = collection.end();
for (iterator it = collection.begin(); it != end; ++it)
delete *(MappedType*)&it->second;
}
template<typename T, typename U, typename V, typename W, typename X>
inline void deleteAllValues(HashMap<T, U, V, W, X>& collection)
inline void deleteAllValues(const HashMap<T, U, V, W, X>& collection)
{
deleteAllPairSeconds<typename HashMap<T, U, V, W, X>::MappedType>(collection);
}
......
......@@ -32,7 +32,7 @@ namespace WTF {
template<typename Value, typename HashFunctions, typename Traits> class HashSet;
template<typename Value, typename HashFunctions, typename Traits>
void deleteAllValues(HashSet<Value, HashFunctions, Traits>&);
void deleteAllValues(const HashSet<Value, HashFunctions, Traits>&);
template<typename ValueArg, typename HashArg = typename DefaultHash<ValueArg>::Hash,
typename TraitsArg = HashTraits<ValueArg> > class HashSet {
......@@ -91,7 +91,7 @@ namespace WTF {
void refAll();
void derefAll();
friend void deleteAllValues<>(HashSet&);
friend void deleteAllValues<>(const HashSet&);
HashTableType m_impl;
};
......@@ -294,14 +294,14 @@ namespace WTF {
template<typename ValueType, typename HashTableType>
void deleteAllValues(HashTableType& collection)
{
typedef typename HashTableType::iterator iterator;
typedef typename HashTableType::const_iterator iterator;
iterator end = collection.end();
for (iterator it = collection.begin(); it != end; ++it)
delete *(ValueType*)&*it;
}
template<typename T, typename U, typename V>
inline void deleteAllValues(HashSet<T, U, V>& collection)
inline void deleteAllValues(const HashSet<T, U, V>& collection)
{
deleteAllValues<typename HashSet<T, U, V>::ValueType>(collection.m_impl);
}
......
......@@ -27,14 +27,14 @@
#if PLATFORM(WIN)
inline float roundf(float num)
{
return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f);
}
#include <xmath.h>
inline long lroundf(float num)
{
return num > 0 ? num + 0.5f : ceilf(num - 0.5f);
}
inline bool isinf(double num) { return !_finite(num); }
inline bool isnan(double num) { return _isnan(num); }
inline long lround(double num) { return num > 0 ? num + 0.5 : ceil(num - 0.5); }
inline long lroundf(float num) { return num > 0 ? num + 0.5f : ceilf(num - 0.5f); }
inline double round(double num) { return num > 0 ? floor(num + 0.5) : ceil(num - 0.5); }
inline float roundf(float num) { return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f); }
inline bool signbit(double num) { return _copysign(1.0, num) < 0; }
#endif
......@@ -579,11 +579,11 @@ namespace WTF {
}
template<typename T, size_t inlineCapacity>
void deleteAllValues(Vector<T, inlineCapacity>& collection)
void deleteAllValues(const Vector<T, inlineCapacity>& collection)
{
typedef Vector<T, inlineCapacity> Vec;
typename Vec::iterator end = collection.end();
for (typename Vec::iterator it = collection.begin(); it != end; ++it)
typedef typename Vector<T, inlineCapacity>::const_iterator iterator;
iterator end = collection.end();
for (iterator it = collection.begin(); it != end; ++it)
delete *it;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment