chromium/third_party/blink/renderer/platform/wtf/key_value_pair.h

/*
 * Copyright (C) 2007 Apple Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_KEY_VALUE_PAIR_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_KEY_VALUE_PAIR_H_

#include <utility>

#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/type_traits.h"

namespace WTF {

template <typename KeyTypeArg, typename ValueTypeArg>
struct KeyValuePair {};

IsWeak<KeyValuePair<K, V>>;

IsTraceable<KeyValuePair<K, V>>;

template <typename KeyTraitsArg,
          typename ValueTraitsArg,
          typename P = KeyValuePair<typename KeyTraitsArg::TraitType,
                                    typename ValueTraitsArg::TraitType>>
struct KeyValuePairHashTraits
    : TwoFieldsHashTraits<P, &P::key, &P::value, KeyTraitsArg, ValueTraitsArg> {
  using TraitType = P;
  using KeyTraits = KeyTraitsArg;
  using ValueTraits = ValueTraitsArg;

  // Even non-traceable keys need to have their trait set. This is because
  // non-traceable keys still need to be processed concurrently for checking
  // empty/deleted state.
  static constexpr bool kCanTraceConcurrently =
      KeyTraits::kCanTraceConcurrently &&
      (ValueTraits::kCanTraceConcurrently ||
       !IsTraceable<typename ValueTraits::TraitType>::value);
};

HashTraits<KeyValuePair<Key, Value>>;

namespace internal {

template <typename T, bool NeedsStackCheck = IsTraceable<T>::value>
class IteratorAdapterBase {};

IteratorAdapterBase<T, true>;

}  // namespace internal

template <typename HashTableType,
          typename KeyType,
          typename MappedType,
          typename Enable = void>
struct HashTableConstKeysIterator;
template <typename HashTableType,
          typename KeyType,
          typename MappedType,
          typename Enable = void>
struct HashTableConstValuesIterator;
template <typename HashTableType,
          typename KeyType,
          typename MappedType,
          typename Enable = void>
struct HashTableKeysIterator;
template <typename HashTableType,
          typename KeyType,
          typename MappedType,
          typename Enable = void>
struct HashTableValuesIterator;

HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>>;

HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>>;

HashTableConstKeysIterator<HashTableType, KeyType, MappedType>;

HashTableConstValuesIterator<HashTableType, KeyType, MappedType>;

HashTableKeysIterator<HashTableType, KeyType, MappedType>;

HashTableValuesIterator<HashTableType, KeyType, MappedType>;

template <typename T, typename U, typename V>
inline bool operator==(const HashTableConstKeysIterator<T, U, V>& a,
                       const HashTableConstKeysIterator<T, U, V>& b) {}

template <typename T, typename U, typename V>
inline bool operator!=(const HashTableConstKeysIterator<T, U, V>& a,
                       const HashTableConstKeysIterator<T, U, V>& b) {}

template <typename T, typename U, typename V>
inline bool operator==(const HashTableConstValuesIterator<T, U, V>& a,
                       const HashTableConstValuesIterator<T, U, V>& b) {}

template <typename T, typename U, typename V>
inline bool operator!=(const HashTableConstValuesIterator<T, U, V>& a,
                       const HashTableConstValuesIterator<T, U, V>& b) {}

template <typename T, typename U, typename V>
inline bool operator==(const HashTableKeysIterator<T, U, V>& a,
                       const HashTableKeysIterator<T, U, V>& b) {}

template <typename T, typename U, typename V>
inline bool operator!=(const HashTableKeysIterator<T, U, V>& a,
                       const HashTableKeysIterator<T, U, V>& b) {}

template <typename T, typename U, typename V>
inline bool operator==(const HashTableValuesIterator<T, U, V>& a,
                       const HashTableValuesIterator<T, U, V>& b) {}

template <typename T, typename U, typename V>
inline bool operator!=(const HashTableValuesIterator<T, U, V>& a,
                       const HashTableValuesIterator<T, U, V>& b) {}

}  // namespace WTF

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_KEY_VALUE_PAIR_H_