All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfHash Class Reference

Provides hash function on STL string types and other types. More...

Public Member Functions

size_t operator() (const std::string &s) const
template<class T >
size_t operator() (const TfRefPtr< T > &ptr) const
template<template< class > class X, class T >
size_t operator() (TfWeakPtrFacade< X, T > const &ptr) const
template<class T , class = typename std::enable_if< std::is_same<T, TfAnyWeakPtr>::value>::type>
size_t operator() (const T &ptr) const
TF_API size_t operator() (const TfEnum &e) const
TF_API size_t operator() (const TfType &t) const
template<class T >
size_t operator() (const T *ptr) const
size_t operator() (size_t i) const
TF_API size_t operator() (const TfToken &t) const

Detailed Description

Provides hash function on STL string types and other types.

The TfHash class is a functor as defined by the STL standard: currently, it is defined for:

The TfHash class can be used to implement a TfHashMap with string keys as follows:

* TfHashMap<string, int, TfHash> m;
* m["abc"] = 1;

TfHash()(const char*) is disallowed to avoid confusion of whether the pointer or the string is being hashed. If you want to hash a C-string use TfHashCString and if you want to hash a char* use TfHashCharPtr.

One can also declare, for any types S and T,

* TfHashMap<TfRefPtr<S>, T, TfHash> m1;
* TfHashMap<TfWeakPtr<S>, T, TfHash> m2;
* TfHashMap<TfEnum, T, TfHash> m3;
* TfHashMap<const void*, T, TfHash> m5;
* TfHashMap<size_t, T, TfHash> m6;

Definition at line 86 of file hash.h.

The documentation for this class was generated from the following file: