1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef XPCOM_DS_NSHASHTABLESFWD_H_
8 #define XPCOM_DS_NSHASHTABLESFWD_H_
10 #include "mozilla/Attributes.h"
12 struct PLDHashEntryHdr
;
15 class MOZ_IS_REFPTR nsCOMPtr
;
18 class MOZ_IS_REFPTR RefPtr
;
20 template <class EntryType
>
21 class MOZ_NEEDS_NO_VTABLE_TYPE nsTHashtable
;
23 template <class DataType
, class UserDataType
>
24 class nsDefaultConverter
;
26 template <class KeyClass
, class DataType
, class UserDataType
,
27 class Converter
= nsDefaultConverter
<DataType
, UserDataType
>>
28 class nsBaseHashtable
;
30 template <class KeyClass
, class T
>
31 class nsClassHashtable
;
33 template <class KeyClass
, class PtrType
>
34 class nsRefCountedHashtable
;
37 * templated hashtable class maps keys to interface pointers.
38 * See nsBaseHashtable for complete declaration.
39 * @deprecated This is going to be removed. Use nsTHashMap instead.
40 * @param KeyClass a wrapper-class for the hashtable key, see nsHashKeys.h
41 * for a complete specification.
42 * @param Interface the interface-type being wrapped
43 * @see nsClassHashtable, nsTHashMap
45 template <class KeyClass
, class Interface
>
46 using nsInterfaceHashtable
=
47 nsRefCountedHashtable
<KeyClass
, nsCOMPtr
<Interface
>>;
50 * templated hashtable class maps keys to reference pointers.
51 * See nsBaseHashtable for complete declaration.
52 * @deprecated This is going to be removed. Use nsTHashMap instead.
53 * @param KeyClass a wrapper-class for the hashtable key, see nsHashKeys.h
54 * for a complete specification.
55 * @param PtrType the reference-type being wrapped
56 * @see nsClassHashtable, nsTHashMap
58 template <class KeyClass
, class ClassType
>
59 using nsRefPtrHashtable
= nsRefCountedHashtable
<KeyClass
, RefPtr
<ClassType
>>;
61 namespace mozilla::detail
{
62 template <class KeyType
, class = void>
64 } // namespace mozilla::detail
67 * A universal hash map that maps some KeyType to some DataType. It can be used
68 * for any DataType, including RefPtr<T>, nsCOMPtr<T> and UniquePtr<T>.
70 * For the default hash keys types, the appropriate hash key class is determined
71 * automatically, so you can just specify `nsTHashMap<uint32_t,
72 * RefPtr<Foo>>`, for example.
74 * If you require custom hash behaviour (e.g. case insensitive string handling),
75 * you can still specify a hash key class derived from PLDHashEntryHdr
78 * If you need to use a custom UserDataType, use nsBaseHashtable (or
79 * nsTHashtable) directly. However, you should double-check if that's really
82 template <class KeyType
, class DataType
>
84 nsBaseHashtable
<typename
mozilla::detail::nsKeyClass
<KeyType
>::type
,
87 template <class KeyClass
>
90 template <class KeyType
>
92 nsTBaseHashSet
<typename
mozilla::detail::nsKeyClass
<KeyType
>::type
>;
94 #endif // XPCOM_DS_NSHASHTABLESFWD_H_