All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
stl.h File Reference
+ Include dependency graph for stl.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TfGet< N >
 Function object for retrieving the N'th element of a std::pair or std::tuple. 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<class Container , class Key >
Container::mapped_type const * TfMapLookupPtr (Container const &map, Key const &key)
 
template<typename T >
std::pair< T, T > TfOrderedPair (T a, T b)
 Return an std::pair in sorted order.
 
template<class T >
void TfReset (T &obj)
 Reset obj to be an empty, space-optimized object.
 
template<class Key , class Value , class Hash , class Equal , class Alloc >
void TfReset (TfHashMap< Key, Value, Hash, Equal, Alloc > &hash)
 Specialize for TfHashMap to make minimally sized hashes.
 
template<class Value , class Hash , class Equal , class Alloc >
void TfReset (TfHashSet< Value, Hash, Equal, Alloc > &hash)
 Specialize for TfHashSet to make minimally sized hashes.
 
template<class InputIterator1 , class InputIterator2 , class OutputIterator >
void TfOrderedSetDifference (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result)
 Produce a sequence consisting of the set difference of [first1, last1) and [first2, last2), while maintaining the relative order of the first sequence.
 
template<class BackInsertionSequence , class InputIterator1 , class InputIterator2 >
BackInsertionSequence TfOrderedSetDifferenceToContainer (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
 Produce a sequence consisting of the set difference of [first1, last1) and [first2, last2), while maintaining the relative order of the first sequence.
 
template<class InputIterator1 , class InputIterator2 , class OutputIterator >
void TfOrderedUniquingSetDifference (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result)
 Produce a sequence consisting of the set difference of the unique elements in [first1, last1) and [first2, last2), while maintaining the relative order of the first sequence.
 
template<class BackInsertionSequence , class InputIterator1 , class InputIterator2 >
BackInsertionSequence TfOrderedUniquingSetDifferenceToContainer (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
 Produce a sequence consisting of the set difference of the unique elements in [first1, last1) and [first2, last2), while maintaining the relative order of the first sequence.
 

Function Documentation

◆ TfMapLookupPtr()

Container::mapped_type const * TfMapLookupPtr ( Container const &  map,
Key const &  key 
)

Definition at line 132 of file stl.h.

◆ TfOrderedSetDifference()

void TfOrderedSetDifference ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
InputIterator2  last2,
OutputIterator  result 
)

Produce a sequence consisting of the set difference of [first1, last1) and [first2, last2), while maintaining the relative order of the first sequence.

No particular order is required for either range, but elements must have a strict weak order provided by operator<.

If an element appears multiple times in either the first or second sequence, the number of occurrences in the output is the difference between the first sequence and the second (or zero if there are more occurrences in the second sequence). For example, if the first sequence is (1, 3, 3, 1) and the second sequence is (2, 3, 2), the result will be (1, 3, 1).

Definition at line 220 of file stl.h.

◆ TfOrderedSetDifferenceToContainer()

BackInsertionSequence TfOrderedSetDifferenceToContainer ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
InputIterator2  last2 
)

Produce a sequence consisting of the set difference of [first1, last1) and [first2, last2), while maintaining the relative order of the first sequence.

No particular order is required for either range, but elements must have a strict weak order provided by operator<.

If an element appears multiple times in either the first or second sequence, the number of occurrences in the output is the difference between the first sequence and the second (or zero if there are more occurrences in the second sequence). For example, if the first sequence is (1, 3, 3, 1) and the second sequence is (2, 3, 2), the result will be (1, 3, 1).

Definition at line 252 of file stl.h.

◆ TfOrderedUniquingSetDifference()

void TfOrderedUniquingSetDifference ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
InputIterator2  last2,
OutputIterator  result 
)

Produce a sequence consisting of the set difference of the unique elements in [first1, last1) and [first2, last2), while maintaining the relative order of the first sequence.

No particular order is required for either range, but elements must have a strict weak order provided by operator<.

If an element appears multiple times in the first sequence, it appears either zero or one times in the output. It appears zero times if it appears in the second sequence, and one time if it does not. For example, if the first sequence is (1, 3, 3, 1) and the second sequence is (2, 3, 2), the result will be (1).

Definition at line 274 of file stl.h.

◆ TfOrderedUniquingSetDifferenceToContainer()

BackInsertionSequence TfOrderedUniquingSetDifferenceToContainer ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
InputIterator2  last2 
)

Produce a sequence consisting of the set difference of the unique elements in [first1, last1) and [first2, last2), while maintaining the relative order of the first sequence.

No particular order is required for either range, but elements must have a strict weak order provided by operator<.

If an element appears multiple times in the first sequence, it appears either zero or one times in the output. It appears zero times if it appears in the second sequence, and one time if it does not. For example, if the first sequence is (1, 3, 3, 1) and the second sequence is (2, 3, 2), the result will be (1).

Definition at line 305 of file stl.h.

◆ TfReset() [1/3]

void TfReset ( T &  obj)
inline

Reset obj to be an empty, space-optimized object.

This can be used to clear c++ containers and reclaim their memory. For instance, std::vector::clear() will not reclaim any memory, even if the vector previously had a large number of elements. Often, this is what you want because the vector is later filled again. But sometimes you want to reclaim the memory, and this function will do that.

As another example, gcc's hash_map and hash_set do not clear their bucket lists when they themselves are cleared. This can lead to poor performance due to ever-growing bucket lists for hashes that are repeatedly filled, cleared, and filled again. TfReset will avoid this by effectively clearing the bucket list.

This function requires that the expression T().swap(obj) where obj is of type T& be valid. This is true for many classes, including the standard containers.

Definition at line 170 of file stl.h.

◆ TfReset() [2/3]

void TfReset ( TfHashMap< Key, Value, Hash, Equal, Alloc > &  hash)
inline

Specialize for TfHashMap to make minimally sized hashes.

Definition at line 178 of file stl.h.

◆ TfReset() [3/3]

void TfReset ( TfHashSet< Value, Hash, Equal, Alloc > &  hash)
inline

Specialize for TfHashSet to make minimally sized hashes.

Definition at line 197 of file stl.h.