7#ifndef PXR_EXEC_VDF_VECTOR_ITERATOR_H
8#define PXR_EXEC_VDF_VECTOR_ITERATOR_H
12#include "pxr/exec/vdf/api.h"
13#include "pxr/exec/vdf/boxedContainer.h"
14#include "pxr/exec/vdf/compressedIndexMapping.h"
15#include "pxr/exec/vdf/vectorData.h"
19PXR_NAMESPACE_OPEN_SCOPE
38 const size_t dataEndIndex = _end - _begin;
39 return _dataIndex == dataEndIndex;
48 return _begin[_dataIndex];
79 size_t _GetIndex()
const {
80 return _mapping->logicalStartIndex + _logicalOffset;
85 size_t _dataIndex = 0;
87 size_t _logicalOffset = 0;
93 const T *_begin =
nullptr;
94 const T *_end =
nullptr;
111 if (_dataIndex == _mapping->dataEndIndex) {
123 while (!IsAtEnd() && _GetIndex() < idx) {
127 return !IsAtEnd() && _GetIndex() == idx;
132 const Vdf_VectorData::Info &info)
134 if (ARCH_UNLIKELY(info.compressedIndexMapping)) {
135 const Vdf_CompressedIndexMapping::_BlockMappings& mappings =
136 info.compressedIndexMapping->_blockMappings;
137 const size_t numValues = mappings.empty()
139 : mappings.back().dataEndIndex;
140 _begin =
reinterpret_cast<const T*
>(info.data);
141 _end =
reinterpret_cast<const T*
>(info.data) + numValues;
143 _mapping = mappings.data();
145 else if (info.layout != Vdf_VectorData::Info::Layout::Boxed) {
146 const size_t numValues = info.size == 0
148 : info.last - info.first + 1;
149 _begin =
reinterpret_cast<const T*
>(info.data);
150 _end =
reinterpret_cast<const T*
>(info.data) + numValues;
152 _localMapping.logicalStartIndex = info.first;
153 _localMapping.dataEndIndex = numValues;
154 _mapping = &_localMapping;
158 BoxedVectorType *boxedVector =
159 reinterpret_cast<BoxedVectorType*
>(info.data);
160 const size_t numValues = boxedVector->
size();
161 _begin = boxedVector->data();
162 _end = boxedVector->data() + numValues;
164 _localMapping.logicalStartIndex = 0;
165 _localMapping.dataEndIndex = numValues;
166 _mapping = &_localMapping;
170PXR_NAMESPACE_CLOSE_SCOPE
This simple container stores multiple values that flow through the network as a single data flow elem...
size_t size() const
Returns the number of elements stored in this container.
This class is used to abstract away knowledge of the cache data used for each node.
A read-only iterator over values held by a VdfVector.
bool AdvanceTo(size_t idx)
Advances this to a data element at or past idx.
const T & operator*() const
Returns the data element pointed to by this.
bool IsAtEnd() const
Returns true if this does not point to an element in the vector.
VdfVectorIterator()=default
Construct an iterator that is at end and not associated with a vector.
VdfVectorIterator & operator++()
Advances the iterator to the next data element.
#define TF_DEV_AXIOM(cond)
The same as TF_AXIOM, but compiled only in dev builds.
A mapping that relates logical blocks of indices to actual stored data when the data is compressed by...