28 #ifndef vtkLabelMapLookup_h
29 #define vtkLabelMapLookup_h
31 #include <unordered_set>
49 this->CachedValue =
static_cast<T
>(values[0]);
50 this->CachedOutValue =
static_cast<T
>(values[0]);
51 this->CachedOutValueInitialized =
false;
57 if (label == this->CachedValue)
62 else if (this->CachedOutValueInitialized && label == this->CachedOutValue)
98 for (
int vidx = 0; vidx < numValues; vidx++)
100 Map.push_back(static_cast<T>(values[vidx]));
113 if (std::find(this->Map.begin(), this->Map.end(), label) != this->Map.end())
115 this->CachedValue = label;
120 this->CachedOutValue = label;
121 this->CachedOutValueInitialized =
true;
128 template <
typename T>
131 std::unordered_set<T>
Map;
136 for (
int vidx = 0; vidx < numValues; vidx++)
138 Map.insert(static_cast<T>(values[vidx]));
151 if (this->Map.find(label) != this->Map.end())
153 this->CachedValue = label;
158 this->CachedOutValue = label;
159 this->CachedOutValueInitialized =
true;
168 template <
typename T>
170 const double* values,
vtkIdType numLabels)
177 else if (numLabels < 20)
std::unordered_set< T > Map
bool IsLabelValueInCache(T label, bool &inLabelSet)
bool CachedOutValueInitialized
provide an efficient numeric label lookup
virtual bool IsLabelValue(T label)=0
bool IsLabelValue(T label) override
SingleLabelValue(const double *values)
LabelVector(const double *values, int numValues)
LabelSet(const double *values, int numValues)
vtkLabelMapLookup(const double *values, int vtkNotUsed(numValues))
static vtkLabelMapLookup< T > * CreateLabelLookup(const double *values, vtkIdType numLabels)
bool IsLabelValue(T label) override
bool IsLabelValue(T label) override
virtual ~vtkLabelMapLookup()=default