- 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: https://svn.webkit.org/repository/webkit/trunk@14728
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+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.
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);
}
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 {
void refAll();
void derefAll();
- friend void deleteAllValues<>(HashSet&);
+ friend void deleteAllValues<>(const HashSet&);
HashTableType m_impl;
};
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);
}
#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
}
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;
}