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

Method SortFileNames

IO/Core/vtkSortFileNames.cxx:476–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

474}
475
476void vtkSortFileNames::SortFileNames(vtkStringArray* input, vtkStringArray* output)
477{
478 // convert vtkStringArray into an STL vector
479 std::vector<std::string> fileNames;
480 vtkIdType numberOfStrings = input->GetNumberOfValues();
481 for (vtkIdType j = 0; j < numberOfStrings; j++)
482 {
483 std::string& fileName = input->GetValue(j);
484
485 // skip anything that is a directory
486 if (this->SkipDirectories && vtksys::SystemTools::FileIsDirectory(fileName))
487 {
488 continue;
489 }
490
491 // build a new list
492 fileNames.push_back(fileName);
493 }
494
495 // perform the sort according to the options that are set
496 if (this->IgnoreCase)
497 {
498 if (this->NumericSort)
499 {
500 // numeric sort without case sensitivity
501 std::sort(fileNames.begin(), fileNames.end(), vtkCompareFileNamesNumericIgnoreCase);
502 }
503 else
504 {
505 // lexicographic sort without case sensitivity
506 std::sort(fileNames.begin(), fileNames.end(), vtkCompareFileNamesIgnoreCase);
507 }
508 }
509 else
510 {
511 if (this->NumericSort)
512 {
513 // numeric sort
514 std::sort(fileNames.begin(), fileNames.end(), vtkCompareFileNamesNumeric);
515 }
516 else
517 {
518 // lexicographic sort (the default)
519 std::sort(fileNames.begin(), fileNames.end());
520 }
521 }
522
523 // build the output
524 std::vector<std::string>::iterator iter = fileNames.begin();
525 while (iter < fileNames.end())
526 {
527 output->InsertNextValue(*iter++);
528 }
529}
530
531void vtkSortFileNames::Execute()
532{

Callers 1

ExecuteMethod · 0.95

Calls 7

sortFunction · 0.50
GetNumberOfValuesMethod · 0.45
GetValueMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
InsertNextValueMethod · 0.45

Tested by

no test coverage detected