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/. */ 6 7 #ifndef XPCOM_DS_NSHASHTABLESFWD_H_ 8 #define XPCOM_DS_NSHASHTABLESFWD_H_ 9 10 #include "mozilla/Attributes.h" 11 12 struct PLDHashEntryHdr; 13 14 template <class T> 15 class MOZ_IS_REFPTR nsCOMPtr; 16 17 template <class T> 18 class MOZ_IS_REFPTR RefPtr; 19 20 template <class EntryType> 21 class MOZ_NEEDS_NO_VTABLE_TYPE nsTHashtable; 22 23 template <class DataType, class UserDataType> 24 class nsDefaultConverter; 25 26 template <class KeyClass, class DataType, class UserDataType, 27 class Converter = nsDefaultConverter<DataType, UserDataType>> 28 class nsBaseHashtable; 29 30 template <class KeyClass, class T> 31 class nsClassHashtable; 32 33 template <class KeyClass, class PtrType> 34 class nsRefCountedHashtable; 35 36 /** 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 44 */ 45 template <class KeyClass, class Interface> 46 using nsInterfaceHashtable = 47 nsRefCountedHashtable<KeyClass, nsCOMPtr<Interface>>; 48 49 /** 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 57 */ 58 template <class KeyClass, class ClassType> 59 using nsRefPtrHashtable = nsRefCountedHashtable<KeyClass, RefPtr<ClassType>>; 60 61 namespace mozilla::detail { 62 template <class KeyType> 63 struct nsKeyClass; 64 } // namespace mozilla::detail 65 66 /** 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>. 69 * 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. 73 * 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 76 * explicitly. 77 * 78 * If you need to use a custom UserDataType, use nsBaseHashtable (or 79 * nsTHashtable) directly. However, you should double-check if that's really 80 * necessary. 81 */ 82 template <class KeyType, class DataType> 83 using nsTHashMap = 84 nsBaseHashtable<typename mozilla::detail::nsKeyClass<KeyType>::type, 85 DataType, DataType>; 86 87 template <class KeyClass> 88 class nsTBaseHashSet; 89 90 template <class KeyType> 91 using nsTHashSet = 92 nsTBaseHashSet<typename mozilla::detail::nsKeyClass<KeyType>::type>; 93 94 #endif // XPCOM_DS_NSHASHTABLESFWD_H_ 95