All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stl.h File Reference
+ Include dependency graph for stl.h:

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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<class T >
void TfReset (T &obj)
 Reset obj to be an empty, space-optimized object. More...
 
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. More...
 
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. More...
 
template<class T >
boost::call_traits< T >::param_type TfIdentity (typename boost::call_traits< T >::param_type arg)
 An unary function that represents the identity function; it takes a single argument arg, and returns arg. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Function Documentation

boost::call_traits<T>::param_type TfIdentity ( typename boost::call_traits< T >::param_type  arg)
inline

An unary function that represents the identity function; it takes a single argument arg, and returns arg.

This is similar to the sgi extension std::identity<T>.

Definition at line 233 of file stl.h.

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 250 of file stl.h.

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 282 of file stl.h.

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 304 of file stl.h.

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 335 of file stl.h.

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 189 of file stl.h.

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

Specialize for TfHashMap to make minimally sized hashes.

Definition at line 197 of file stl.h.

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

Specialize for TfHashSet to make minimally sized hashes.

Definition at line 216 of file stl.h.