MCPcopy Create free account
hub / github.com/Kitware/VTK / UpdateLookup

Method UpdateLookup

Common/Core/vtkStringArray.cxx:795–826  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

793
794//------------------------------------------------------------------------------
795void vtkStringArray::UpdateLookup()
796{
797 if (!this->Lookup)
798 {
799 this->Lookup = new vtkStringArrayLookup();
800 this->Lookup->SortedArray = vtkStringArray::New();
801 this->Lookup->IndexArray = vtkIdList::New();
802 }
803 if (this->Lookup->Rebuild)
804 {
805 int numComps = this->GetNumberOfComponents();
806 vtkIdType numTuples = this->GetNumberOfTuples();
807 this->Lookup->SortedArray->Initialize();
808 this->Lookup->SortedArray->SetNumberOfComponents(numComps);
809 this->Lookup->SortedArray->SetNumberOfTuples(numTuples);
810 this->Lookup->IndexArray->SetNumberOfIds(numComps * numTuples);
811 std::vector<std::pair<ValueType, vtkIdType>> v;
812 v.reserve(numComps * numTuples);
813 for (vtkIdType i = 0; i < numComps * numTuples; i++)
814 {
815 v.emplace_back(this->Array[i], i);
816 }
817 std::sort(v.begin(), v.end());
818 for (vtkIdType i = 0; i < numComps * numTuples; i++)
819 {
820 this->Lookup->SortedArray->SetValue(i, v[i].first);
821 this->Lookup->IndexArray->SetId(i, v[i].second);
822 }
823 this->Lookup->Rebuild = false;
824 this->Lookup->CachedUpdates.clear();
825 }
826}
827
828//------------------------------------------------------------------------------
829vtkIdType vtkStringArray::LookupValue(vtkVariant var)

Callers 1

LookupValueMethod · 0.95

Calls 15

SetNumberOfIdsMethod · 0.80
NewFunction · 0.70
sortFunction · 0.50
GetNumberOfComponentsMethod · 0.45
GetNumberOfTuplesMethod · 0.45
InitializeMethod · 0.45
SetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45
reserveMethod · 0.45
emplace_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected