From 2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 7 May 2012 11:21:11 +0200 Subject: Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286) --- Source/JavaScriptCore/wtf/HashSet.h | 261 ------------------------------------ 1 file changed, 261 deletions(-) delete mode 100644 Source/JavaScriptCore/wtf/HashSet.h (limited to 'Source/JavaScriptCore/wtf/HashSet.h') diff --git a/Source/JavaScriptCore/wtf/HashSet.h b/Source/JavaScriptCore/wtf/HashSet.h deleted file mode 100644 index 33cb14daa..000000000 --- a/Source/JavaScriptCore/wtf/HashSet.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef WTF_HashSet_h -#define WTF_HashSet_h - -#include -#include - -namespace WTF { - - struct IdentityExtractor; - - template class HashSet; - template - void deleteAllValues(const HashSet&); - template - void fastDeleteAllValues(const HashSet&); - - template::Hash, - typename TraitsArg = HashTraits > class HashSet { - WTF_MAKE_FAST_ALLOCATED; - private: - typedef HashArg HashFunctions; - typedef TraitsArg ValueTraits; - - public: - typedef typename ValueTraits::TraitType ValueType; - - private: - typedef HashTable HashTableType; - - public: - typedef HashTableConstIteratorAdapter iterator; - typedef HashTableConstIteratorAdapter const_iterator; - - void swap(HashSet&); - - int size() const; - int capacity() const; - bool isEmpty() const; - - iterator begin() const; - iterator end() const; - - iterator find(const ValueType&) const; - bool contains(const ValueType&) const; - - // An alternate version of find() that finds the object by hashing and comparing - // with some other type, to avoid the cost of type conversion. HashTranslator - // must have the following function members: - // static unsigned hash(const T&); - // static bool equal(const ValueType&, const T&); - // FIXME: We should reverse the order of the template arguments so that callers - // can just pass the translator and let the compiler deduce T. - template iterator find(const T&) const; - template bool contains(const T&) const; - - // The return value is a pair of an interator to the new value's location, - // and a bool that is true if an new entry was added. - pair add(const ValueType&); - - // An alternate version of add() that finds the object by hashing and comparing - // with some other type, to avoid the cost of type conversion if the object is already - // in the table. HashTranslator must have the following function members: - // static unsigned hash(const T&); - // static bool equal(const ValueType&, const T&); - // static translate(ValueType&, const T&, unsigned hashCode); - // FIXME: We should reverse the order of the template arguments so that callers - // can just pass the translator and let the compiler deduce T. - template pair add(const T&); - - void remove(const ValueType&); - void remove(iterator); - void clear(); - - private: - friend void deleteAllValues<>(const HashSet&); - friend void fastDeleteAllValues<>(const HashSet&); - - HashTableType m_impl; - }; - - struct IdentityExtractor { - template static const T& extract(const T& t) { return t; } - }; - - template - struct HashSetTranslatorAdapter { - template static unsigned hash(const T& key) { return Translator::hash(key); } - template static bool equal(const T& a, const U& b) { return Translator::equal(a, b); } - template static void translate(T& location, const U& key, const U&, unsigned hashCode) - { - Translator::translate(location, key, hashCode); - } - }; - - template - inline void HashSet::swap(HashSet& other) - { - m_impl.swap(other.m_impl); - } - - template - inline int HashSet::size() const - { - return m_impl.size(); - } - - template - inline int HashSet::capacity() const - { - return m_impl.capacity(); - } - - template - inline bool HashSet::isEmpty() const - { - return m_impl.isEmpty(); - } - - template - inline typename HashSet::iterator HashSet::begin() const - { - return m_impl.begin(); - } - - template - inline typename HashSet::iterator HashSet::end() const - { - return m_impl.end(); - } - - template - inline typename HashSet::iterator HashSet::find(const ValueType& value) const - { - return m_impl.find(value); - } - - template - inline bool HashSet::contains(const ValueType& value) const - { - return m_impl.contains(value); - } - - template - template - typename HashSet::iterator - inline HashSet::find(const T& value) const - { - return m_impl.template find >(value); - } - - template - template - inline bool HashSet::contains(const T& value) const - { - return m_impl.template contains >(value); - } - - template - inline pair::iterator, bool> HashSet::add(const ValueType& value) - { - return m_impl.add(value); - } - - template - template - inline pair::iterator, bool> - HashSet::add(const T& value) - { - return m_impl.template addPassingHashCode >(value, value); - } - - template - inline void HashSet::remove(iterator it) - { - if (it.m_impl == m_impl.end()) - return; - m_impl.internalCheckTableConsistency(); - m_impl.removeWithoutEntryConsistencyCheck(it.m_impl); - } - - template - inline void HashSet::remove(const ValueType& value) - { - remove(find(value)); - } - - template - inline void HashSet::clear() - { - m_impl.clear(); - } - - template - void deleteAllValues(HashTableType& collection) - { - typedef typename HashTableType::const_iterator iterator; - iterator end = collection.end(); - for (iterator it = collection.begin(); it != end; ++it) - delete *it; - } - - template - inline void deleteAllValues(const HashSet& collection) - { - deleteAllValues::ValueType>(collection.m_impl); - } - - template - void fastDeleteAllValues(HashTableType& collection) - { - typedef typename HashTableType::const_iterator iterator; - iterator end = collection.end(); - for (iterator it = collection.begin(); it != end; ++it) - fastDelete(*it); - } - - template - inline void fastDeleteAllValues(const HashSet& collection) - { - fastDeleteAllValues::ValueType>(collection.m_impl); - } - - template - inline void copyToVector(const HashSet& collection, W& vector) - { - typedef typename HashSet::const_iterator iterator; - - vector.resize(collection.size()); - - iterator it = collection.begin(); - iterator end = collection.end(); - for (unsigned i = 0; it != end; ++it, ++i) - vector[i] = *it; - } - -} // namespace WTF - -using WTF::HashSet; - -#endif /* WTF_HashSet_h */ -- cgit v1.2.1