|
HDK
|
#include <UN_DataBuffer.h>
Public Member Functions | |
| UN_DataBuffer ()=default | |
| UN_DataBuffer (UN_DataSize size) | |
| T | stealData (UN_DataIndex index) |
| Returns a moved value from an entry in a data buffer. More... | |
| template<typename OP > | |
| void | updateData (UN_DataIndex index, const OP &op) |
| void | addData (UN_DataIndex index, const T &init_value=T()) |
| Adds an entry slot to the data buffer. More... | |
| void | appendData (const T &value, exint count) |
| Appends count copies of the given value. More... | |
| void | appendData (const UN_DataBuffer< T > &src, UN_DataIndex start, UN_DataSize size) |
| Appends a span of entries from another buffer. More... | |
| void | clear () |
| Resets the data to an empty buffer. More... | |
| UN_DataSize | size () const |
| Returns the number of elements held in the data buffer. More... | |
| void | setCapacityIfNeeded (UN_DataSize min_capacity) |
| bool | isValidIndex (UN_DataIndex index) const |
| Return true if given index is valid. More... | |
| void | setData (UN_DataIndex index, const T &value) |
| Sets the data value for the entry at a given index. More... | |
| void | setData (UN_DataIndex index, T &&value) |
| Sets the data value for the entry at a given index. More... | |
| const T & | getDataRef (UN_DataIndex index) const |
| const T & | operator[] (UN_DataIndex index) const |
Vectorized memory buffer that contains data entries for a particular aspect for a group of items of the same kind in the graph. Each entry in the buffer holds a piece of data for a single item. For example, a buffer may hold names for the nodes, so each buffer entry holds a name for a single node. This class is templated on the type of the entries it stores.
Definition at line 27 of file UN_DataBuffer.h.
|
default |
|
inline |
Definition at line 34 of file UN_DataBuffer.h.
|
inline |
Adds an entry slot to the data buffer.
Definition at line 74 of file UN_DataBuffer.h.
|
inline |
Appends count copies of the given value.
Definition at line 86 of file UN_DataBuffer.h.
|
inline |
Appends a span of entries from another buffer.
Definition at line 92 of file UN_DataBuffer.h.
|
inline |
Resets the data to an empty buffer.
Definition at line 102 of file UN_DataBuffer.h.
|
inline |
Returns the data value for the entry at a given index. Note, this buffer class does not provide a getter method that returns a mutable (non-const) reference to the underlying data to avoid aliasing, which is problematic for threading. However, it provides stealData() to move the value out of buffer.
Definition at line 51 of file UN_DataBuffer.h.
|
inline |
Return true if given index is valid.
Definition at line 115 of file UN_DataBuffer.h.
|
inline |
Returns the data value for the entry at a given index. Note, this buffer class does not provide a getter method that returns a mutable (non-const) reference to the underlying data to avoid aliasing, which is problematic for threading. However, it provides stealData() to move the value out of buffer.
Definition at line 53 of file UN_DataBuffer.h.
|
inline |
Definition at line 111 of file UN_DataBuffer.h.
|
inline |
Sets the data value for the entry at a given index.
Definition at line 40 of file UN_DataBuffer.h.
|
inline |
Sets the data value for the entry at a given index.
Definition at line 42 of file UN_DataBuffer.h.
|
inline |
Returns the number of elements held in the data buffer.
Definition at line 106 of file UN_DataBuffer.h.
|
inline |
Returns a moved value from an entry in a data buffer.
Definition at line 58 of file UN_DataBuffer.h.
|
inline |
Updates a data entry value in-place inside the data buffer. For complex data types (eg, dictionaries or arrays) it is faster than getting and setting the value (although stealing and setting back a moved value is comparable). This is a convenient and useful idiom, that tries to avoid the buffer aliasing issues, that cause problems in multithreading. Intended usage: updateData(index, [&key, &value](auto &dict) { dict[key] = value; });
Definition at line 70 of file UN_DataBuffer.h.