Loading...
Searching...
No Matches
VtArrayEditBuilder< ELEM > Class Template Reference

A builder type that produces instances of VtArrayEdit representing sequences of array edit operations. More...

#include <arrayEditBuilder.h>

Public Types

using Ops = Vt_ArrayEditOps
 
using Edit = VtArrayEdit< ELEM >
 
using Array = typename Edit::Array
 
using ElementType = typename Edit::ElementType
 
using Self = VtArrayEditBuilder
 

Public Member Functions

 VtArrayEditBuilder ()=default
 Default construct a builder with no instructions.
 
SelfWrite (ElementType const &elem, int64_t index)
 Add an instruction that writes elem to index.
 
SelfWriteRef (int64_t srcIndex, int64_t dstIndex)
 Add an instruction that writes the element at srcIndex to dstIndex.
 
SelfInsert (ElementType const &elem, int64_t index)
 Add an instruction that inserts elem at index.
 
SelfInsertRef (int64_t srcIndex, int64_t dstIndex)
 Add an instruction that inserts a copy of the element at srcIndex at dstIndex.
 
SelfPrepend (ElementType const &elem)
 Equivalent to Insert(elem, 0)
 
SelfPrependRef (int64_t srcIndex)
 Equivalent to InsertRef(srcIndex, 0)
 
SelfAppend (ElementType const &elem)
 Equivalent to Insert(elem, EndIndex)
 
SelfAppendRef (int64_t srcIndex)
 Equivalent to InsertRef(srcIndex, EndIndex)
 
SelfEraseRef (int64_t index)
 Add an instruction that erases the element at index.
 
SelfMinSize (int64_t size)
 Add an instruction that, if the array's size is less than size, appends value-initialized elements to the array until it has size.
 
SelfMinSize (int64_t size, ElementType const &fill)
 Add an instruction that, if the array's size is less than size, appends copies of fill to the array until it has size.
 
SelfMaxSize (int64_t size)
 Add an instruction that, if the array's size is greater than size erases trailing elements until it has size.
 
SelfSetSize (int64_t size)
 Add an instruction that, if the array's size is not equal to size, then items are either appended or erased as in MinSize() and MaxSize() until the array has size size.
 
SelfSetSize (int64_t size, ElementType const &fill)
 Add an instruction that, if the array's size is not equal to size, then items are either appended or erased as in MinSize() and MaxSize() until the array has size size.
 
VtArrayEdit< ELEM > FinalizeAndReset ()
 Return a VtArrayEdit that performs the edits as specified by prior calls to this class's other member functions, then clear this builder's state, leaving it as if it was default constructed.
 

Static Public Member Functions

static VtArrayEdit< ELEM > Optimize (VtArrayEdit< ELEM > &&in)
 Given a VtArrayEdit that may have been composed from several, attempt to produce a smaller, optimized edit that acts identically.
 
static void GetSerializationData (VtArrayEdit< ELEM > const &edit, VtArray< ELEM > *valuesOut, std::vector< int64_t > *indexesOut)
 
static VtArrayEdit< ELEM > CreateFromSerializationData (VtArray< ELEM > const &values, TfSpan< int64_t > indexes)
 

Static Public Attributes

static constexpr auto EndIndex = Vt_ArrayEditOps::EndIndex
 A special index value meaning one-past-the-end of the array, for use in Insert() instructions.
 

Detailed Description

template<class ELEM>
class VtArrayEditBuilder< ELEM >

A builder type that produces instances of VtArrayEdit representing sequences of array edit operations.

Callers will typically construct a builder and invoke its member functions, like Write(), Insert(), Erase() repeatedly, then call FinalizeAndReset() to produce a VtArrayEdit representing the sequence of operations.

Definition at line 65 of file arrayEditBuilder.h.

Member Typedef Documentation

◆ Array

using Array = typename Edit::Array

Definition at line 70 of file arrayEditBuilder.h.

◆ Edit

using Edit = VtArrayEdit<ELEM>

Definition at line 69 of file arrayEditBuilder.h.

◆ ElementType

using ElementType = typename Edit::ElementType

Definition at line 71 of file arrayEditBuilder.h.

◆ Ops

using Ops = Vt_ArrayEditOps

Definition at line 68 of file arrayEditBuilder.h.

◆ Self

Definition at line 72 of file arrayEditBuilder.h.

Constructor & Destructor Documentation

◆ VtArrayEditBuilder()

VtArrayEditBuilder ( )
default

Default construct a builder with no instructions.

Member Function Documentation

◆ Append()

Self & Append ( ElementType const &  elem)
inline

Equivalent to Insert(elem, EndIndex)

Definition at line 133 of file arrayEditBuilder.h.

◆ AppendRef()

Self & AppendRef ( int64_t  srcIndex)
inline

Equivalent to InsertRef(srcIndex, EndIndex)

Definition at line 140 of file arrayEditBuilder.h.

◆ CreateFromSerializationData()

static VtArrayEdit< ELEM > CreateFromSerializationData ( VtArray< ELEM > const &  values,
TfSpan< int64_t >  indexes 
)
inlinestatic

Definition at line 229 of file arrayEditBuilder.h.

◆ EraseRef()

Self & EraseRef ( int64_t  index)
inline

Add an instruction that erases the element at index.

The index may be negative in which case the array index is computed by adding to the array size to produce a final index. When applied, if index is out-of-bounds, this instruction is ignored.

Definition at line 149 of file arrayEditBuilder.h.

◆ FinalizeAndReset()

VtArrayEdit< ELEM > FinalizeAndReset ( )
inline

Return a VtArrayEdit that performs the edits as specified by prior calls to this class's other member functions, then clear this builder's state, leaving it as if it was default constructed.

Definition at line 195 of file arrayEditBuilder.h.

◆ GetSerializationData()

static void GetSerializationData ( VtArrayEdit< ELEM > const &  edit,
VtArray< ELEM > *  valuesOut,
std::vector< int64_t > *  indexesOut 
)
inlinestatic

Definition at line 214 of file arrayEditBuilder.h.

◆ Insert()

Self & Insert ( ElementType const &  elem,
int64_t  index 
)
inline

Add an instruction that inserts elem at index.

The index may be negative in which case the array index is computed by adding to the array size to produce a final index. The index may also be EndIndex, which indicates insertion at the end. When applied, if index is out-of-bounds and not EndIndex, this instruction is ignored.

Definition at line 104 of file arrayEditBuilder.h.

◆ InsertRef()

Self & InsertRef ( int64_t  srcIndex,
int64_t  dstIndex 
)
inline

Add an instruction that inserts a copy of the element at srcIndex at dstIndex.

The indexes may be negative in which case the array indexes are computed by adding to the array size to produce the final indexes. The dstIndex may also be EndIndex, which indicates insertion at the end. When applied, if srcIndex is out-of-bounds or dstIndex is out of bounds and not EndIndex, this instruction is ignored.

Definition at line 115 of file arrayEditBuilder.h.

◆ MaxSize()

Self & MaxSize ( int64_t  size)
inline

Add an instruction that, if the array's size is greater than size erases trailing elements until it has size.

Definition at line 170 of file arrayEditBuilder.h.

◆ MinSize() [1/2]

Self & MinSize ( int64_t  size)
inline

Add an instruction that, if the array's size is less than size, appends value-initialized elements to the array until it has size.

Definition at line 156 of file arrayEditBuilder.h.

◆ MinSize() [2/2]

Self & MinSize ( int64_t  size,
ElementType const &  fill 
)
inline

Add an instruction that, if the array's size is less than size, appends copies of fill to the array until it has size.

Definition at line 163 of file arrayEditBuilder.h.

◆ Optimize()

VtArrayEdit< ELEM > Optimize ( VtArrayEdit< ELEM > &&  in)
static

Given a VtArrayEdit that may have been composed from several, attempt to produce a smaller, optimized edit that acts identically.

If in is the identity, return it unmodified.

Definition at line 254 of file arrayEditBuilder.h.

◆ Prepend()

Self & Prepend ( ElementType const &  elem)
inline

Equivalent to Insert(elem, 0)

Definition at line 121 of file arrayEditBuilder.h.

◆ PrependRef()

Self & PrependRef ( int64_t  srcIndex)
inline

Equivalent to InsertRef(srcIndex, 0)

Definition at line 127 of file arrayEditBuilder.h.

◆ SetSize() [1/2]

Self & SetSize ( int64_t  size)
inline

Add an instruction that, if the array's size is not equal to size, then items are either appended or erased as in MinSize() and MaxSize() until the array has size size.

Definition at line 178 of file arrayEditBuilder.h.

◆ SetSize() [2/2]

Self & SetSize ( int64_t  size,
ElementType const &  fill 
)
inline

Add an instruction that, if the array's size is not equal to size, then items are either appended or erased as in MinSize() and MaxSize() until the array has size size.

If items are appended they are copies of fill.

Definition at line 187 of file arrayEditBuilder.h.

◆ Write()

Self & Write ( ElementType const &  elem,
int64_t  index 
)
inline

Add an instruction that writes elem to index.

The index may be negative in which case the array index is computed by adding to the array size to produce a final index. When applied, if index is out-of-bounds, this instruction is ignored.

Definition at line 85 of file arrayEditBuilder.h.

◆ WriteRef()

Self & WriteRef ( int64_t  srcIndex,
int64_t  dstIndex 
)
inline

Add an instruction that writes the element at srcIndex to dstIndex.

These indexes may be negative in which case the array indexes are computed by adding to the array size to produce final indexes. When applied, if index is out-of-bounds, this instruction is ignored.

Definition at line 94 of file arrayEditBuilder.h.

Member Data Documentation

◆ EndIndex

constexpr auto EndIndex = Vt_ArrayEditOps::EndIndex
staticconstexpr

A special index value meaning one-past-the-end of the array, for use in Insert() instructions.

Definition at line 76 of file arrayEditBuilder.h.


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