|
HDK
|
Maintains a mapping from data ID to data index in the data buffer. More...
#include <UN_DataIndexMap.h>
Classes | |
| class | IDIterator |
| Iterator for traversing valid data IDs in the map. More... | |
| class | OrderedIDIterator |
| Iterator for traversing valid data IDs in the map in an ordered fashion. More... | |
Public Types | |
| using | IDRange = UT_IteratorRange< IDIterator > |
| using | OrderedIDRange = UT_IteratorRange< OrderedIDIterator > |
Public Member Functions | |
| UN_DataIndexMap () | |
| Constructor. More... | |
| std::pair< UN_DataID, UN_DataIndex > | addEntry () |
| std::pair< UN_DataID, UN_DataIndex > | findOrAddEntry (UN_DataID data_id) |
| bool | removeEntry (UN_DataID data_id) |
| void | removeAllEntries (bool reset_next_id) |
| void | clear (bool reset_next_id=false) |
| bool | isValid (UN_DataID data_id) const |
| Returns true if the given ID refers to a valid entry in the map. More... | |
| UN_DataIndex | indexFromID (UN_DataID data_id) const |
| Returns an index into a data array buffer given the data ID. More... | |
| IDRange | idRange () const |
| OrderedIDRange | orderedIDRange () const |
| UT_Array< UN_DataID > | ids () const |
| UT_Array< UN_DataID > | sortedIDs () const |
| UN_DataSize | size () const |
| Returns the number of valid data itmes in the map. More... | |
| UN_DataSize | indexSize () const |
| UN_DataSize | idSize () const |
| UN_DataSize | dataBufferSize () const |
| UN_DataSize | freeDataBufferSize () const |
| UN_DataSize | usedDataBufferSize () const |
| UN_DataMergeInfo | merge (const UN_DataIndexMap &src_map, bool combine_id_zero=false) |
Maintains a mapping from data ID to data index in the data buffer.
Definition at line 23 of file UN_DataIndexMap.h.
| using UN_DataIndexMap::IDRange = UT_IteratorRange< IDIterator > |
Returns a range for iterating valid data IDs (order is not defined). Best for fast iteration without large memory footprint, but yields non-sorted IDs.
Definition at line 190 of file UN_DataIndexMap.h.
Returns a range for iterating valid data IDs in an ascending order. Best for iterating without large memory footprint, yields sorted IDs, but does not perform any explicit sorting (scans past invalid holes by checking the validity of IDs) so is only slightly slower than idRange().
Definition at line 201 of file UN_DataIndexMap.h.
| UN_DataIndexMap::UN_DataIndexMap | ( | ) |
Constructor.
| std::pair< UN_DataID, UN_DataIndex > UN_DataIndexMap::addEntry | ( | ) |
Adds a new data entry to the map. Returns a pair, where the first component is the data ID that uniquely identifies it in the graph, and the second component is the index to the data entry in the data buffer arrays.
| void UN_DataIndexMap::clear | ( | bool | reset_next_id = false | ) |
Clears the map to an empty state, with no map entries.
| 'reset_next_id' | If true, the data ID generator is reset to zero. This may be useful if a graph loads and clears nodes repeatedly, but has the danger of anyone holding the previous IDs thinking that this data is still valid. So use this option with great caution!!! |
|
inline |
Returns the size of the data buffers that use indexing based on this map. The size is calculated as the largest known index issued by this map plus one.
Definition at line 249 of file UN_DataIndexMap.h.
| std::pair< UN_DataID, UN_DataIndex > UN_DataIndexMap::findOrAddEntry | ( | UN_DataID | data_id | ) |
Adds a new data entry to the map, forcing it to have the given ID. If a given ID is already in the map, returns the existing index.
|
inline |
Returns the number of free slots in the data buffer. Ie, the buffer consists of data entry slots that are either occupied or free, and this menthod returns the free slots count.
Definition at line 255 of file UN_DataIndexMap.h.
|
inline |
Definition at line 191 of file UN_DataIndexMap.h.
Returns an array of valid (non-sorted) IDs. Builds an array, by quickly traversing the map keys, but yields non-sorted IDs.
Definition at line 212 of file UN_DataIndexMap.h.
|
inline |
Returns the upper limit on the numerical value of the valid data IDs issued by this container. Ie, maximum ID plus one.
Definition at line 243 of file UN_DataIndexMap.h.
|
inline |
Returns an index into a data array buffer given the data ID.
Definition at line 72 of file UN_DataIndexMap.h.
|
inline |
Returns the upper limit on the valid indices issued by this container. Ie, maximum index value plus one.
Definition at line 238 of file UN_DataIndexMap.h.
|
inline |
Returns true if the given ID refers to a valid entry in the map.
Definition at line 60 of file UN_DataIndexMap.h.
| UN_DataMergeInfo UN_DataIndexMap::merge | ( | const UN_DataIndexMap & | src_map, |
| bool | combine_id_zero = false |
||
| ) |
Merges another index map into this one, creating mappings for the data entries to merged/copied from the given source.
If combine_id_zero is true, the data for the ID zero is not mapped to a brand new data slot, but is combined with existing slot ID of zero. Some data containers use ID of zero for a special entry that is treated differently than the other ones. Notably, the node data container uses ID of zero for the root node, and the root node from the src should not become a regular node in dst. Instead, src root ID maps to dst root ID and their data is combined.
|
inline |
Definition at line 202 of file UN_DataIndexMap.h.
|
inline |
Removes all the data IDs entries from the map.
| 'reset_next_id' | If true, the data ID generator is reset to zero. |
Definition at line 45 of file UN_DataIndexMap.h.
| bool UN_DataIndexMap::removeEntry | ( | UN_DataID | data_id | ) |
Removes the data ID/Index lookup entry from the map. Returns true on successs; false if ID was not found in the map.
|
inline |
Returns the number of valid data itmes in the map.
Definition at line 233 of file UN_DataIndexMap.h.
Returns an array of valid IDs sorded in an ascending order. Builds an array, but incurs sorting cost, so it's slower than ids().
Definition at line 224 of file UN_DataIndexMap.h.
|
inline |
Returns the number of valid data entries in the data buffer. Ie, the buffer consists of data entry slots that are either occupied or free, and this menthod returns the occupied slots count.
Definition at line 261 of file UN_DataIndexMap.h.