HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SdfPathTable< MappedType > Class Template Reference

#include <pathTable.h>

Classes

class  Iterator
 
struct  NodeHandle
 

Public Types

typedef SdfPath key_type
 
typedef MappedType mapped_type
 
typedef std::pair< key_type,
mapped_type
value_type
 
typedef Iterator< value_type,
_Entry * > 
iterator
 
typedef Iterator< const
value_type, const _Entry * > 
const_iterator
 
typedef std::pair< iterator, bool > _IterBoolPair
 Result type for insert(). More...
 

Public Member Functions

 SdfPathTable ()
 Default constructor. More...
 
 SdfPathTable (SdfPathTable const &other)
 Copy constructor. More...
 
 SdfPathTable (SdfPathTable &&other)
 Move constructor. More...
 
 ~SdfPathTable ()
 Destructor. More...
 
SdfPathTableoperator= (SdfPathTable const &other)
 Copy assignment. More...
 
SdfPathTableoperator= (SdfPathTable &&other)
 Move assignment. More...
 
iterator begin ()
 Return an iterator to the start of the table. More...
 
const_iterator begin () const
 Return a const_iterator to the start of the table. More...
 
iterator end ()
 Return an iterator denoting the end of the table. More...
 
const_iterator end () const
 Return a const_iterator denoting the end of the table. More...
 
bool erase (SdfPath const &path)
 
void erase (iterator const &i)
 
iterator find (SdfPath const &path)
 
const_iterator find (SdfPath const &path) const
 
std::pair< iterator, iteratorFindSubtreeRange (SdfPath const &path)
 
std::pair< const_iterator,
const_iterator
FindSubtreeRange (SdfPath const &path) const
 
size_t count (SdfPath const &path) const
 Return 1 if there is an element for path in the table, otherwise 0. More...
 
size_t size () const
 Return the number of elements in the table. More...
 
bool empty () const
 Return true if this table is empty. More...
 
_IterBoolPair insert (value_type const &value)
 
_IterBoolPair insert (NodeHandle &&node)
 
mapped_typeoperator[] (SdfPath const &path)
 
void clear ()
 
void ClearInParallel ()
 
void swap (SdfPathTable &other)
 Swap this table's contents with other. More...
 
std::vector< size_t > GetBucketSizes () const
 Return a vector of the count of elements in each bucket. More...
 
void UpdateForRename (const SdfPath &oldName, const SdfPath &newName)
 
template<typename Callback >
void ParallelForEach (Callback const &visitFn)
 
template<typename Callback >
void ParallelForEach (Callback const &visitFn) const
 

Friends

template<class , class >
class Iterator
 

Detailed Description

template<class MappedType>
class SdfPathTable< MappedType >

A mapping from SdfPath to MappedType, somewhat similar to map<SdfPath, MappedType> and TfHashMap<SdfPath, MappedType>, but with key differences. Notably:

Works exclusively with absolute paths.

Inserting a path p also implicitly inserts all of p's ancestors.

Erasing a path p also implicitly erases all of p's descendants.

The table has an order: it's a preordering of the paths in the table, but with arbitrary sibling order. Given a path p in the table, all other paths in the table with p as a prefix appear contiguously, immediately following p. For example, suppose a table contains the paths:

{'/a/b/c', '/a', '/a/d', '/', '/a/b'}

Then there are two possible valid orderings:

['/', '/a', '/a/d', '/a/b', '/a/b/c'] ['/', '/a', '/a/b', '/a/b/c', '/a/d']

In addition to the ordinary map and TfHashMap methods, this class provides a method FindSubtreeRange, which, given a path p, returns a pair of iterators [b, e) defining a range such that for every iterator i in [b, e), i->first is either equal to p or is prefixed by p.

Iterator Invalidation

Like most other node-based containers, iterators are only invalidated when the element they refer to is removed from the table. Note however, that since removing the element with path p also implicitly removes all elements with paths prefixed by p, a call to erase(i) may invalidate many iterators.

Definition at line 82 of file pathTable.h.

Member Typedef Documentation

template<class MappedType>
typedef std::pair<iterator, bool> SdfPathTable< MappedType >::_IterBoolPair

Result type for insert().

Definition at line 312 of file pathTable.h.

template<class MappedType>
typedef Iterator<const value_type, const _Entry *> SdfPathTable< MappedType >::const_iterator

Definition at line 309 of file pathTable.h.

template<class MappedType>
typedef Iterator<value_type, _Entry *> SdfPathTable< MappedType >::iterator

Definition at line 308 of file pathTable.h.

template<class MappedType>
typedef SdfPath SdfPathTable< MappedType >::key_type

Definition at line 86 of file pathTable.h.

template<class MappedType>
typedef MappedType SdfPathTable< MappedType >::mapped_type

Definition at line 87 of file pathTable.h.

template<class MappedType>
typedef std::pair<key_type, mapped_type> SdfPathTable< MappedType >::value_type

Definition at line 88 of file pathTable.h.

Constructor & Destructor Documentation

template<class MappedType>
SdfPathTable< MappedType >::SdfPathTable ( )
inline

Default constructor.

Definition at line 398 of file pathTable.h.

template<class MappedType>
SdfPathTable< MappedType >::SdfPathTable ( SdfPathTable< MappedType > const &  other)
inline

Copy constructor.

Definition at line 401 of file pathTable.h.

template<class MappedType>
SdfPathTable< MappedType >::SdfPathTable ( SdfPathTable< MappedType > &&  other)
inline

Move constructor.

Definition at line 428 of file pathTable.h.

template<class MappedType>
SdfPathTable< MappedType >::~SdfPathTable ( )
inline

Destructor.

Definition at line 438 of file pathTable.h.

Member Function Documentation

template<class MappedType>
iterator SdfPathTable< MappedType >::begin ( void  )
inline

Return an iterator to the start of the table.

Definition at line 458 of file pathTable.h.

template<class MappedType>
const_iterator SdfPathTable< MappedType >::begin ( void  ) const
inline

Return a const_iterator to the start of the table.

Definition at line 466 of file pathTable.h.

template<class MappedType>
void SdfPathTable< MappedType >::clear ( void  )
inline

Remove all elements from the table, leaving size() == 0. Note that this function will not shrink the number of buckets used for the hash table. To do that, swap this instance with a default constructed instance. See also TfReset.

Definition at line 620 of file pathTable.h.

template<class MappedType>
void SdfPathTable< MappedType >::ClearInParallel ( )
inline

Equivalent to clear(), but destroy contained objects in parallel. This requires that running the contained objects' destructors is thread-safe.

Definition at line 636 of file pathTable.h.

template<class MappedType>
size_t SdfPathTable< MappedType >::count ( SdfPath const &  path) const
inline

Return 1 if there is an element for path in the table, otherwise 0.

Definition at line 561 of file pathTable.h.

template<class MappedType>
bool SdfPathTable< MappedType >::empty ( void  ) const
inline

Return true if this table is empty.

Definition at line 569 of file pathTable.h.

template<class MappedType>
iterator SdfPathTable< MappedType >::end ( void  )
inline

Return an iterator denoting the end of the table.

Definition at line 474 of file pathTable.h.

template<class MappedType>
const_iterator SdfPathTable< MappedType >::end ( void  ) const
inline

Return a const_iterator denoting the end of the table.

Definition at line 479 of file pathTable.h.

template<class MappedType>
bool SdfPathTable< MappedType >::erase ( SdfPath const &  path)
inline

Remove the element with path path from the table as well as all elements whose paths are prefixed by path. Return true if any elements were removed, false otherwise.

Note that since descendant paths are also erased, size() may be decreased by more than one after calling this function.

Definition at line 489 of file pathTable.h.

template<class MappedType>
void SdfPathTable< MappedType >::erase ( iterator const &  i)
inline

Remove the element pointed to by i from the table as well as all elements whose paths are prefixed by i->first. i must be a valid iterator for this table.

Note that since descendant paths are also erased, size() may be decreased by more than one after calling this function.

Definition at line 503 of file pathTable.h.

template<class MappedType>
iterator SdfPathTable< MappedType >::find ( SdfPath const &  path)
inline

Return an iterator to the element corresponding to path, or end() if there is none.

Definition at line 514 of file pathTable.h.

template<class MappedType>
const_iterator SdfPathTable< MappedType >::find ( SdfPath const &  path) const
inline

Return a const_iterator to the element corresponding to path, or end() if there is none.

Definition at line 527 of file pathTable.h.

template<class MappedType>
std::pair<iterator, iterator> SdfPathTable< MappedType >::FindSubtreeRange ( SdfPath const &  path)
inline

Return a pair of iterators [b, e), describing the maximal range such that for all i in the range, i->first is b->first or is prefixed by b->first.

Definition at line 542 of file pathTable.h.

template<class MappedType>
std::pair<const_iterator, const_iterator> SdfPathTable< MappedType >::FindSubtreeRange ( SdfPath const &  path) const
inline

Return a pair of const_iterators [b, e), describing the maximal range such that for all i in the range, i->first is b->first or is prefixed by b->first.

Definition at line 553 of file pathTable.h.

template<class MappedType>
std::vector<size_t> SdfPathTable< MappedType >::GetBucketSizes ( ) const
inline

Return a vector of the count of elements in each bucket.

Definition at line 660 of file pathTable.h.

template<class MappedType>
_IterBoolPair SdfPathTable< MappedType >::insert ( value_type const &  value)
inline

Insert value into the table, and additionally insert default entries for all ancestral paths of value.first that do not already exist in the table.

Return a pair of iterator and bool. The iterator points to the inserted element, the bool indicates whether insertion was successful. The bool is true if value was successfully inserted and false if an element with path value.first was already present in the map.

Note that since ancestral paths are also inserted, size() may be increased by more than one after calling this function.

Definition at line 582 of file pathTable.h.

template<class MappedType>
_IterBoolPair SdfPathTable< MappedType >::insert ( NodeHandle &&  node)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Insert the entry held by node into this table. If the insertion is successful, the contents of node are moved-from and indeterminate. Otherwise if the insertion is unsuccessful, the contents of node are unmodified.

Definition at line 598 of file pathTable.h.

template<class MappedType>
SdfPathTable& SdfPathTable< MappedType >::operator= ( SdfPathTable< MappedType > const &  other)
inline

Copy assignment.

Definition at line 444 of file pathTable.h.

template<class MappedType>
SdfPathTable& SdfPathTable< MappedType >::operator= ( SdfPathTable< MappedType > &&  other)
inline

Move assignment.

Definition at line 451 of file pathTable.h.

template<class MappedType>
mapped_type& SdfPathTable< MappedType >::operator[] ( SdfPath const &  path)
inline

Shorthand for the following, where t is an SdfPathTable<T>.

t.insert(value_type(path, mapped_type())).first->second

Definition at line 612 of file pathTable.h.

template<class MappedType>
template<typename Callback >
void SdfPathTable< MappedType >::ParallelForEach ( Callback const &  visitFn)
inline

ParallelForEach: parallel iteration over all of the key-value pairs in the path table. The type of visitFn should be a callable, taking a (const SdfPath&, mapped_type&), representing the loop body. Note: since this function is run in parallel, visitFn is responsible for synchronizing access to any non-pathtable state.

Definition at line 697 of file pathTable.h.

template<class MappedType>
template<typename Callback >
void SdfPathTable< MappedType >::ParallelForEach ( Callback const &  visitFn) const
inline

ParallelForEach: const version, runnable on a const path table and taking a (const SdfPath&, const mapped_type&) input.

Definition at line 714 of file pathTable.h.

template<class MappedType>
size_t SdfPathTable< MappedType >::size ( void  ) const
inline

Return the number of elements in the table.

Definition at line 566 of file pathTable.h.

template<class MappedType>
void SdfPathTable< MappedType >::swap ( SdfPathTable< MappedType > &  other)
inline

Swap this table's contents with other.

Definition at line 653 of file pathTable.h.

template<class MappedType>
void SdfPathTable< MappedType >::UpdateForRename ( const SdfPath oldName,
const SdfPath newName 
)
inline

Replaces all prefixes from oldName to newName. Note that oldName and newName need to be silbing paths (ie. their parent paths must be the same).

Definition at line 673 of file pathTable.h.

Friends And Related Function Documentation

template<class MappedType>
template<class , class >
friend class Iterator
friend

Definition at line 201 of file pathTable.h.


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