| Index: Source/wtf/LiteralSet.h
|
| diff --git a/Source/core/platform/Task.h b/Source/wtf/LiteralSet.h
|
| similarity index 68%
|
| copy from Source/core/platform/Task.h
|
| copy to Source/wtf/LiteralSet.h
|
| index fe0270a8ec78113c954aa5a1fd5d2758d23a89eb..3dd52b40e582f65237c212de064cdb54e03dfe92 100644
|
| --- a/Source/core/platform/Task.h
|
| +++ b/Source/wtf/LiteralSet.h
|
| @@ -28,30 +28,47 @@
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#ifndef Task_h
|
| -#define Task_h
|
| +#ifndef WTF_LiteralSet_h
|
| +#define WTF_LiteralSet_h
|
|
|
| -#include "wtf/Functional.h"
|
| -#include <public/WebThread.h>
|
| +#include "wtf/NonCopyingSort.h"
|
|
|
| -namespace WebCore {
|
| +#include <algorithm>
|
|
|
| -class Task : public WebKit::WebThread::Task {
|
| +namespace WTF {
|
| +
|
| +template<typename T, typename Comparer>
|
| +class LiteralSet {
|
| public:
|
| - explicit Task(const Closure& closure)
|
| - : m_closure(closure)
|
| + LiteralSet()
|
| + : m_values(0)
|
| + , m_size(0)
|
| + {
|
| + }
|
| +
|
| + void init(T values[], size_t size)
|
| {
|
| + ASSERT(!isInitialized());
|
| + m_values = values;
|
| + m_size = size;
|
| + nonCopyingSort(m_values, m_values + m_size, Comparer::lessThan);
|
| }
|
|
|
| - virtual void run() OVERRIDE
|
| + bool contains(const T& value)
|
| {
|
| - m_closure();
|
| + ASSERT(isInitialized());
|
| + return std::binary_search(m_values, m_values + m_size, value, Comparer::lessThan);
|
| }
|
|
|
| + bool isInitialized() { return !m_size; }
|
| +
|
| private:
|
| - Closure m_closure;
|
| + T* m_values;
|
| + size_t m_size;
|
| };
|
|
|
| -} // namespace WebCore
|
| +} // namespace WTF
|
| +
|
| +using WTF::LiteralSet;
|
|
|
| -#endif // Task_h
|
| +#endif
|
|
|