Loading...
Searching...
No Matches
VdfVector Class Reference

This class is used to abstract away knowledge of the cache data used for each node. More...

#include <vector.h>

+ Inheritance diagram for VdfVector:

Classes

class  DebugPrintable
 An ostream-able object wrapping a VdfVector instance, as well as a mask indicating which elements in the wrapped vector should be streamed out. More...
 
class  ReadAccessor
 A read-only accessor for low-level acces to the contents of the VdfVector. More...
 
class  ReadWriteAccessor
 A read/write accessor for low-level access to the contents of the VdfVector. More...
 

Public Types

enum  ConstructBoxedCopyTag { ConstructBoxedCopy }
 Copy constructor with boxing. More...
 

Public Member Functions

 VdfVector (const VdfVector &rhs)
 Copy constructor.
 
 VdfVector (const VdfVector &rhs, const VdfMask &mask)
 Copy constructor with subset copying.
 
 VdfVector (const VdfVector &rhs, const VdfMask &mask, ConstructBoxedCopyTag)
 
 VdfVector (const VdfVector &rhs, size_t size)
 Construct a vector with the same element type as rhs and of size size.
 
 VdfVector (VdfVector &&rhs)
 Move constructor.
 
 ~VdfVector ()
 Destructor.
 
size_t GetSize () const
 Returns the number of elements held in this vector.
 
bool IsEmpty () const
 Returns whether or not this vector is empty.
 
size_t GetNumStoredElements () const
 Returns the number of elements for which this vector has storage.
 
template<typename TYPE >
void Set (TYPE &&data)
 Forwards data into the vector.
 
template<typename TYPE >
void Set (const Vdf_BoxedContainer< TYPE > &data)
 Copy boxed values into the vector.
 
template<typename TYPE >
void Set (Vdf_BoxedContainer< TYPE > &data)
 
template<typename TYPE >
void Set (const Vdf_BoxedContainer< TYPE > &&data)
 
template<typename TYPE >
void Set (Vdf_BoxedContainer< TYPE > &&data)
 Move boxed values into the vector.
 
template<typename TYPE >
void Resize (size_t size)
 Allocates space for size number of elements.
 
template<typename TYPE >
void Resize (const VdfMask::Bits &bits)
 Allocates space for the elements denoted by bits.
 
void Copy (const VdfVector &rhs, const VdfMask &mask)
 Copies the contents of rhs into this vector.
 
VDF_API void Merge (const VdfVector &rhs, const VdfMask::Bits &bits)
 Merges the contents of rhs into this vector.
 
void Merge (const VdfVector &rhs, const VdfMask &mask)
 Same as Merge(), but takes a VdfMask instead of a bitset.
 
bool Share () const
 Embeds the current vector's existing implementaion into a reference counted implementaion so that the data can be shared without copying.
 
bool IsShared () const
 Returns true if the vector has been shared.
 
bool IsSharable () const
 Returns true if the vector can be shared.
 
template<typename T >
VtArray< T > ExtractAsVtArray (const size_t size, const int offset) const
 Extracts this vector's values into a VtArray<T>.
 
template<typename TYPE >
ReadWriteAccessor< TYPE > GetReadWriteAccessor () const
 GetReadWriteAccessor() allows low level access to the content of the VdfVector via the Vdf_VectorData base class.
 
template<typename TYPE >
ReadAccessor< TYPE > GetReadAccessor () const
 GetReadAccessor() allows low level read-only access to the content of of the VdfVector via the Vdf_VectorData base class.
 
template<typename TYPE >
Vdf_VectorSubrangeAccessor< TYPE > GetSubrangeAccessor () const
 Provide read-only access to the boxed subranges held by this vector.
 
template<typename TYPE >
bool Holds () const
 Checks if a vector holds a specific type.
 
VdfVectoroperator= (const VdfVector &rhs)
 Copies the content of rhs into this vector.
 
VdfVectoroperator= (VdfVector &&rhs)
 Moves the content of rhs into this vector.
 
size_t EstimateElementMemory () const
 Returns the number of bytes necessary to store a single element of this VdfVector.
 
DebugPrintable GetDebugPrintable (const VdfMask &mask) const
 Returns an ostream-able object, which can be used to debug print the contents of this VdfVector, filtered by mask.
 

Protected Attributes

Vdf_VectorData::DataHolder _data
 

Detailed Description

This class is used to abstract away knowledge of the cache data used for each node.

Note that data can be put into a VdfVector only atomically, no incremental adding of elements is possible.

Note that Vdf requires the availability of the default and copy constructor for the given template parameter TYPE. Additional Vdf provides default fallback values via the VdfExecutionTypeRegistry. That is to give types the ability to have empty default constructors (for speed) but at the same time have well definied values to use in case we need to provide a "default".

Definition at line 55 of file vector.h.

Member Enumeration Documentation

◆ ConstructBoxedCopyTag

Copy constructor with boxing.

Definition at line 90 of file vector.h.

Constructor & Destructor Documentation

◆ VdfVector() [1/6]

VdfVector ( const VdfVector rhs)
inline

Copy constructor.

Definition at line 61 of file vector.h.

◆ VdfVector() [2/6]

VdfVector ( const VdfVector rhs,
const VdfMask mask 
)
inline

Copy constructor with subset copying.

Definition at line 71 of file vector.h.

◆ VdfVector() [3/6]

VdfVector ( const VdfVector rhs,
const VdfMask mask,
ConstructBoxedCopyTag   
)
inline

Definition at line 94 of file vector.h.

◆ VdfVector() [4/6]

VdfVector ( const VdfVector rhs,
size_t  size 
)
inline

Construct a vector with the same element type as rhs and of size size.

All elements in this new vector are default constructed.

Definition at line 116 of file vector.h.

◆ VdfVector() [5/6]

VdfVector ( VdfVector &&  rhs)
inline

Move constructor.

Definition at line 131 of file vector.h.

◆ ~VdfVector()

~VdfVector ( )
inline

Destructor.

Definition at line 139 of file vector.h.

◆ VdfVector() [6/6]

VdfVector ( )
inlineprotected

Definition at line 640 of file vector.h.

Member Function Documentation

◆ Copy()

void Copy ( const VdfVector rhs,
const VdfMask mask 
)
inline

Copies the contents of rhs into this vector.

rhs and this vector must be type compatible.

Use this instead of operator= when you want to take advantage of only copying the elements set in mask from the rhs vector.

Definition at line 274 of file vector.h.

◆ EstimateElementMemory()

size_t EstimateElementMemory ( ) const
inline

Returns the number of bytes necessary to store a single element of this VdfVector.

Note that this method estimates the allocated memory, which may not be accurate if the held data is not a value type, or has fields that are not value types.

Definition at line 585 of file vector.h.

◆ ExtractAsVtArray()

VtArray< T > ExtractAsVtArray ( const size_t  size,
const int  offset 
) const
inline

Extracts this vector's values into a VtArray<T>.

If the data has been shared previously, no copying occurs. Otherwise, the data is copied into a new VtArray.

Definition at line 370 of file vector.h.

◆ GetDebugPrintable()

DebugPrintable GetDebugPrintable ( const VdfMask mask) const
inline

Returns an ostream-able object, which can be used to debug print the contents of this VdfVector, filtered by mask.

Definition at line 627 of file vector.h.

◆ GetNumStoredElements()

size_t GetNumStoredElements ( ) const
inline

Returns the number of elements for which this vector has storage.

Definition at line 154 of file vector.h.

◆ GetReadAccessor()

ReadAccessor< TYPE > GetReadAccessor ( ) const
inline

GetReadAccessor() allows low level read-only access to the content of of the VdfVector via the Vdf_VectorData base class.

In order to get the handle to that, this method will do the correct type checking for you.

Definition at line 514 of file vector.h.

◆ GetReadWriteAccessor()

ReadWriteAccessor< TYPE > GetReadWriteAccessor ( ) const
inline

GetReadWriteAccessor() allows low level access to the content of the VdfVector via the Vdf_VectorData base class.

In order to get the handle to that this method will do the correct type checking for you.

Definition at line 449 of file vector.h.

◆ GetSize()

size_t GetSize ( ) const
inline

Returns the number of elements held in this vector.

Definition at line 146 of file vector.h.

◆ GetSubrangeAccessor()

Vdf_VectorSubrangeAccessor< TYPE > GetSubrangeAccessor ( ) const
inline

Provide read-only access to the boxed subranges held by this vector.

While this is a public method, only VdfSubrangeView can make use of the returned Vdf_VectorSubrangeAccessor.

Definition at line 525 of file vector.h.

◆ Holds()

bool Holds ( ) const
inline

Checks if a vector holds a specific type.

Definition at line 534 of file vector.h.

◆ IsEmpty()

bool IsEmpty ( ) const
inline

Returns whether or not this vector is empty.

Definition at line 150 of file vector.h.

◆ IsSharable()

bool IsSharable ( ) const
inline

Returns true if the vector can be shared.

Definition at line 358 of file vector.h.

◆ IsShared()

bool IsShared ( ) const
inline

Returns true if the vector has been shared.

Note: Only used in tests currently.

Definition at line 350 of file vector.h.

◆ Merge() [1/2]

void Merge ( const VdfVector rhs,
const VdfMask mask 
)
inline

Same as Merge(), but takes a VdfMask instead of a bitset.

Definition at line 316 of file vector.h.

◆ Merge() [2/2]

VDF_API void Merge ( const VdfVector rhs,
const VdfMask::Bits bits 
)

Merges the contents of rhs into this vector.

The elements copied from rhs are determined by the mask.

rhs and this vector must be type compatible. Also note, that this vector (the destination vector), must NOT be a compressed vector.

◆ operator=() [1/2]

VdfVector & operator= ( const VdfVector rhs)
inline

Copies the content of rhs into this vector.

This is an expensive operation if rhs has not been shared.

This method does runtime type checking to ensure that both vectors have compatible types.

Definition at line 549 of file vector.h.

◆ operator=() [2/2]

VdfVector & operator= ( VdfVector &&  rhs)
inline

Moves the content of rhs into this vector.

This method does runtime type checking to ensure that both vectors have compatible types.

Definition at line 566 of file vector.h.

◆ Resize() [1/2]

void Resize ( const VdfMask::Bits bits)
inline

Allocates space for the elements denoted by bits.

The vector will be initialized with the default ctor. Note that if this doesn't do anything meaningful (cf. Gf types), memory will be left uninitialized.

Definition at line 244 of file vector.h.

◆ Resize() [2/2]

void Resize ( size_t  size)
inline

Allocates space for size number of elements.

The vector will be initialized with the default ctor. Note that if this doesn't do anything meaningful (cf. Gf types), memory will be left uninitialized.

Definition at line 218 of file vector.h.

◆ Set() [1/5]

void Set ( const Vdf_BoxedContainer< TYPE > &&  data)
inline

Definition at line 195 of file vector.h.

◆ Set() [2/5]

void Set ( const Vdf_BoxedContainer< TYPE > &  data)
inline

Copy boxed values into the vector.

Definition at line 177 of file vector.h.

◆ Set() [3/5]

void Set ( TYPE &&  data)
inline

Forwards data into the vector.

Definition at line 162 of file vector.h.

◆ Set() [4/5]

void Set ( Vdf_BoxedContainer< TYPE > &&  data)
inline

Move boxed values into the vector.

Definition at line 204 of file vector.h.

◆ Set() [5/5]

void Set ( Vdf_BoxedContainer< TYPE > &  data)
inline

Definition at line 189 of file vector.h.

◆ Share()

bool Share ( ) const
inline

Embeds the current vector's existing implementaion into a reference counted implementaion so that the data can be shared without copying.

Mutating the contents of the data holder once shared will cause detachment. Returns true if the sharing was successful.

Note: This method is not thread safe.

Definition at line 327 of file vector.h.

Member Data Documentation

◆ _data

Vdf_VectorData::DataHolder _data
mutableprotected

Definition at line 720 of file vector.h.


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