7 #ifndef PXR_EXEC_VDF_INDEXED_DATA_H
8 #define PXR_EXEC_VDF_INDEXED_DATA_H
19 #include "pxr/base/tf/mallocTag.h"
41 TfAutoMallocTag2 tag(
"Vdf",
"VdfIndexedData::Add");
43 if (!_indices.empty() && index <= _indices.back()) {
47 _indices.push_back(index);
48 _data.push_back(data);
54 return _indices.size();
61 _indices.reserve(size);
68 return _indices.empty();
105 const size_t size = _indices.size();
106 for (
size_t i = startIndex; i <
size; ++i) {
107 if (_indices[i] >= 0 &&
108 static_cast<unsigned int>(_indices[i]) >= currentIndex) {
136 return sizeof(*this) +
137 sizeof(
int)*_indices.capacity() +
138 sizeof(
T)*_data.capacity();
145 template <
class HashState>
147 h.Append(d._indices, d._data);
153 return _indices == rhs._indices &&
160 return !(*
this == rhs);
166 lhs._indices.swap(rhs._indices);
167 lhs._data.swap(rhs._data);
252 std::vector<int> _indices;
255 std::vector<T> _data;
261 operator<<(std::ostream &os, const VdfIndexedData<T> &
data)
263 size_t sz =
data.GetSize();
268 for(
size_t i=0; i<sz; i++) {
269 os <<
'(' <<
data.GetIndex(i) <<
", " <<
data.GetData(i) <<
')';
281 std::vector<int>::const_iterator it = std::lower_bound(
282 _indices.begin(), _indices.end(), currentIndex);
293 if ((&weak == result) ||
294 (&strong == result)) {
295 TF_CODING_ERROR(
"Result indexData must be different than strong or weak.");
301 if (strong._indices.empty()) {
302 result->_indices = weak._indices;
303 result->_data = weak._data;
307 if (weak._indices.empty()) {
308 result->_indices = strong._indices;
309 result->_data = strong._data;
313 std::vector<int> &resultIndices = result->_indices;
314 std::vector<T> &resultData = result->_data;
318 resultIndices.clear();
323 size_t strongIndex = 0;
324 bool strongDone =
false;
326 size_t weakIndex = 0;
327 bool weakDone =
false;
330 const std::vector<int> &strongIndices = strong._indices;
331 const std::vector<int> &weakIndices = weak._indices;
333 size_t numStrongIndices = strongIndices.size();
334 size_t numWeakIndices = weakIndices.size();
338 while ( (weakDone ==
false) || (strongDone ==
false)) {
342 bool useStrongValue =
true;
344 int strongIndexValue = -1;
345 int weakIndexValue = -1;
350 useStrongValue =
false;
351 weakIndexValue = weakIndices[weakIndex];
353 }
else if (weakDone) {
356 strongIndexValue = strongIndices[strongIndex];
363 strongIndexValue = strongIndices[strongIndex];
364 weakIndexValue = weakIndices[weakIndex];
366 if (weakIndexValue < strongIndexValue) {
378 useStrongValue =
false;
389 if (useStrongValue) {
393 resultIndices.push_back(strongIndexValue);
394 resultData.push_back(strong._data[strongIndex]);
396 if (weakIndexValue == strongIndexValue) {
405 resultIndices.push_back(weakIndexValue);
406 resultData.push_back(weak._data[weakIndex]);
411 if (strongIndex >= numStrongIndices) {
414 if (weakIndex >= numWeakIndices) {
421 template <
typename T>
422 constexpr
bool VdfIsEqualityComparable<VdfIndexedData<T>> =
423 VdfIsEqualityComparable<T>;
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
#define PXR_NAMESPACE_OPEN_SCOPE
static const std::vector< T > & _GetReadData(const VdfIndexedData< T > *o)
**But if you need a result
size_t GetFirstDataIndex(size_t currentIndex, size_t startIndex) const
friend void swap(VdfIndexedData &lhs, VdfIndexedData &rhs)
static std::vector< T > & _GetWriteData(VdfIndexedData< T > *o)
size_t GetFirstDataIndex(size_t currentIndex) const
VdfIndexedDataIterator< int > IndexIterator
DataIteratorRange GetDataIterators() const
#define TF_DEV_AXIOM(cond)
bool operator!=(const VdfIndexedData &rhs) const
#define __ARCH_PRETTY_FUNCTION__
void Add(int index, VdfByValueOrConstRef< T > data)
static void Compose(VdfIndexedData *result, const VdfIndexedData &weak, const VdfIndexedData &strong)
size_t GetMemoryUsage() const
std::vector< T > & _GetWriteData()
void Reserve(size_t size)
const std::vector< int > & _GetReadIndices() const
std::pair< DataIterator, DataIterator > DataIteratorRange
static std::vector< int > & _GetWriteIndices(VdfIndexedData< T > *o)
GLfloat GLfloat GLfloat GLfloat h
#define PXR_NAMESPACE_CLOSE_SCOPE
bool operator==(const VdfIndexedData &rhs) const
SIM_API const UT_StringHolder distance
typename std::conditional_t< std::is_pointer_v< T >||Vdf_AndTypeIsSmall< T, std::is_arithmetic_v< T >>||Vdf_AndTypeIsSmall< T, std::is_enum_v< T >>, T, const T & > VdfByValueOrConstRef
VdfByValueOrConstRef< T > GetData(size_t i) const
int GetIndex(size_t i) const
static const std::vector< int > & _GetReadIndices(const VdfIndexedData< T > *o)
VdfIndexedDataIterator< T > DataIterator
friend void TfHashAppend(HashState &h, const VdfIndexedData &d)
IndexIteratorRange GetIndexIterators() const
std::pair< IndexIterator, IndexIterator > IndexIteratorRange
std::vector< int > & _GetWriteIndices()
const std::vector< T > & _GetReadData() const