https://mooseframework.inl.gov
Functions
GeochemistrySortedIndicesTest.C File Reference

Go to the source code of this file.

Functions

 TEST (GeochemistrySortedIndicesTest, sortedIndices)
 

Function Documentation

◆ TEST()

TEST ( GeochemistrySortedIndicesTest  ,
sortedIndices   
)

Definition at line 14 of file GeochemistrySortedIndicesTest.C.

15 {
16  std::vector<Real> vec = {1, 2, 5, 3, -2};
17 
18  std::vector<unsigned> ind = GeochemistrySortedIndices::sortedIndices(vec, true);
19  std::vector<unsigned> gold = {4, 0, 1, 3, 2};
20  for (unsigned i = 0; i < 5; ++i)
21  EXPECT_EQ(ind[i], gold[i]);
22 
24  gold = {2, 3, 1, 0, 4};
25  for (unsigned i = 0; i < 5; ++i)
26  EXPECT_EQ(ind[i], gold[i]);
27 }
std::vector< unsigned > sortedIndices(const std::vector< Real > &to_sort, bool ascending)
Produces a vector of indices corresponding to the smallest-to-biggest entries in to_sort (or biggest-...