![]() |
|
Helper functions/classes for STL. More...
Collaboration diagram for C++ STL Utilities:Files | |
| file | stl.h |
Classes | |
| class | TfGet< N > |
| Function object for retrieving the N'th element of a std::pair or std::tuple. More... | |
| class | TfIterator< T, Reverse > |
A simple iterator adapter for STL containers. More... | |
| struct | TfDeleter |
| Function object for deleting any pointer. More... | |
Functions | |
| template<class Container , class Key , class Result > | |
| bool | TfMapLookup (Container const &map, Key const &key, Result *valuePtr) |
Checks if an item exists in a map or a TfHashMap. | |
| template<class Container , class Key , class Result > | |
| const Result | TfMapLookupByValue (Container const &map, Key const &key, const Result &defaultValue) |
Checks if an item exists in a map or a TfHashMap. | |
| template<class Container , class Key > | |
| Container::mapped_type * | TfMapLookupPtr (Container &map, Key const &key) |
Checks if an item exists in a map or TfHashMap, without copying it. | |
| template<typename T > | |
| std::pair< T, T > | TfOrderedPair (T a, T b) |
Return an std::pair in sorted order. | |
Helper functions/classes for STL.
| bool TfMapLookup | ( | Container const & | map, |
| Key const & | key, | ||
| Result * | valuePtr | ||
| ) |
Checks if an item exists in a map or a TfHashMap.
If key exists in map, then this function returns true and the value indexed by key is copied into *valuePtr. Otherwise, *valuePtr is not modified, and false is returned.
Example:
| const Result TfMapLookupByValue | ( | Container const & | map, |
| Key const & | key, | ||
| const Result & | defaultValue | ||
| ) |
Checks if an item exists in a map or a TfHashMap.
If key exists in map, then this function returns the value index by key. Otherwise, defaultValue is returned. Note that the result is returned by value, so this is best used for types that are quick to copy.
Example:
| Container::mapped_type * TfMapLookupPtr | ( | Container & | map, |
| Key const & | key | ||
| ) |
Checks if an item exists in a map or TfHashMap, without copying it.
If key exists in the map, then this function returns a pointer to the value indexed by key. Otherwise, NULL is returned.
Example:
|
inline |
Return an std::pair in sorted order.
This call is a useful helper for maps whose key is an unordered pair of elements. One can either define a new data type such that (a,b) is deemed equivalent to (b,a), or more simply, adopt the convention that a key is always written (a,b) with a < b.