1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-FileCopyrightText: Copyright 2011 Sandia Corporation
// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
/**
* @class vtkDescriptiveStatistics
* @brief Private implementation for bivariate
* statistics algorithms.
*
*
* The main purpose of this class is to avoid exposure of STL container
* through the APIs of the vtkStatistics classes APIs
*
* @par Thanks:
* Thanks to Philippe Pebay and David Thompson from Sandia National Laboratories
* for implementing this class.
*/
#ifndef vtkStatisticsAlgorithmPrivate_h
#define vtkStatisticsAlgorithmPrivate_h
#include "vtkStdString.h"
#include <set> // used to iterate over internal organs
VTK_ABI_NAMESPACE_BEGIN
class vtkStatisticsAlgorithmPrivate
{
public:
// --------------------------------------------------------------------
/**
* Empty current set of requests
*/
void ResetRequests() { this->Requests.clear(); }
// --------------------------------------------------------------------
///@{
/**
* Empty current buffer
*/
int ResetBuffer()
{
int rval = this->Buffer.empty() ? 0 : 1;
this->Buffer.clear();
return rval;
}
// --------------------------------------------------------------------
int SetBufferColumnStatus(const char* colName, int status)
{
if (status)
{
return this->Buffer.insert(colName).second ? 1 : 0;
}
else
{
return this->Buffer.erase(colName) ? 1 : 0;
}
}
// --------------------------------------------------------------------
int AddBufferToRequests()
{
bool result = false;
// Don't add empty selections to the list of requests.
if (!this->Buffer.empty())
{
result = this->Requests.insert(this->Buffer).second;
}
return result ? 1 : 0;
}
// --------------------------------------------------------------------
///@}
///@{
/**
* This function does not use the buffer like other column selection methods.
*/
int AddColumnToRequests(const char* col)
{
if (col && *col)
{
std::set<vtkStdString> tmp;
tmp.insert(col);
if (this->Requests.insert(tmp).second)
{
return 1;
}
}
return 0;
}
// --------------------------------------------------------------------
///@}
///@{
/**
* This function does not use the buffer like other column selection methods.
*/
int AddColumnPairToRequests(const char* cola, const char* colb)
{
if (cola && colb && *cola && *colb)
{
std::set<vtkStdString> tmp;
tmp.insert(cola);
tmp.insert(colb);
if (this->Requests.insert(tmp).second)
{
return 1;
}
}
return 0;
}
// --------------------------------------------------------------------
///@}
/**
* Return the number of currently-defined requests
*/
vtkIdType GetNumberOfRequests() { return static_cast<vtkIdType>(this->Requests.size()); }
// --------------------------------------------------------------------
///@{
/**
* Return the number of columns associated with request \a r.
*/
vtkIdType GetNumberOfColumnsForRequest(vtkIdType r)
{
if (r < 0 || r > static_cast<vtkIdType>(this->Requests.size()))
{
return 0;
}
std::set<std::set<vtkStdString>>::iterator it = this->Requests.begin();
for (vtkIdType i = 0; i < r; ++i)
{
++it;
}
return static_cast<vtkIdType>(it->size());
}
// --------------------------------------------------------------------
///@}
///@{
/**
* Provide the name of the \a c-th column of the \a r-th request in \a columnName.
* Returns false if the request or column does not exist and true otherwise.
*/
bool GetColumnForRequest(vtkIdType r, vtkIdType c, vtkStdString& columnName)
{
if (r < 0 || r > static_cast<vtkIdType>(this->Requests.size()) || c < 0)
{
return false;
}
std::set<std::set<vtkStdString>>::const_iterator it = this->Requests.begin();
for (vtkIdType i = 0; i < r; ++i)
{
++it;
}
if (c > static_cast<vtkIdType>(it->size()))
{
return false;
}
std::set<vtkStdString>::const_iterator cit = it->begin();
for (vtkIdType j = 0; j < c; ++j)
{
++cit;
}
columnName = *cit;
return true;
}
///@}
std::set<std::set<vtkStdString>> Requests;
std::set<vtkStdString> Buffer;
};
VTK_ABI_NAMESPACE_END
#endif // vtkStatisticsAlgorithmPrivate_h
// VTK-HeaderTest-Exclude: vtkStatisticsAlgorithmPrivate.h
|