QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
Calculator for summary statistics and aggregates for a list of strings. More...
#include <qgsstringstatisticalsummary.h>
Public Member Functions | |
QgsStringStatisticalSummary (Qgis::StringStatistics stats=Qgis::StringStatistic::All) | |
Constructor for QgsStringStatistics. | |
void | addString (const QString &string) |
Adds a single string to the statistics calculation. | |
void | addValue (const QVariant &value) |
Adds a single variant to the statistics calculation. | |
void | calculate (const QStringList &values) |
Calculates summary statistics for an entire list of strings at once. | |
void | calculateFromVariants (const QVariantList &values) |
Calculates summary statistics for an entire list of variants at once. | |
int | count () const |
Returns the calculated count of values. | |
int | countDistinct () const |
Returns the number of distinct string values. | |
int | countMissing () const |
Returns the number of missing (null) string values. | |
QSet< QString > | distinctValues () const |
Returns the set of distinct string values. | |
void | finalize () |
Must be called after adding all strings with addString() and before retrieving any calculated string statistics. | |
QString | majority () const |
Returns the most common string. | |
QString | max () const |
Returns the maximum (non-null) string value. | |
int | maxLength () const |
Returns the maximum length of strings. | |
double | meanLength () const |
Returns the mean length of strings. | |
QString | min () const |
Returns the minimum (non-null) string value. | |
int | minLength () const |
Returns the minimum length of strings. | |
QString | minority () const |
Returns the least common string. | |
void | reset () |
Resets the calculated values. | |
void | setStatistics (Qgis::StringStatistics stats) |
Sets flags which specify which statistics will be calculated. | |
QVariant | statistic (Qgis::StringStatistic stat) const |
Returns the value of a specified statistic. | |
Qgis::StringStatistics | statistics () const |
Returns flags which specify which statistics will be calculated. | |
Static Public Member Functions | |
static QString | displayName (Qgis::StringStatistic statistic) |
Returns the friendly display name for a statistic. | |
Calculator for summary statistics and aggregates for a list of strings.
Statistics are calculated by calling calculate() and passing a list of strings. The individual statistics can then be retrieved using the associated methods. Note that not all statistics are calculated by default. Statistics which require slower computations are only calculated by specifying the statistic in the constructor or via setStatistics().
Definition at line 43 of file qgsstringstatisticalsummary.h.
QgsStringStatisticalSummary::QgsStringStatisticalSummary | ( | Qgis::StringStatistics | stats = Qgis::StringStatistic::All | ) |
Constructor for QgsStringStatistics.
stats | flags for statistics to calculate |
Definition at line 31 of file qgsstringstatisticalsummary.cpp.
void QgsStringStatisticalSummary::addString | ( | const QString & | string | ) |
Adds a single string to the statistics calculation.
Calling this method allows strings to be added to the calculation one at a time. For large quantities of strings this may be more efficient then first adding all the strings to a list and calling calculate().
string | string to add |
Definition at line 64 of file qgsstringstatisticalsummary.cpp.
void QgsStringStatisticalSummary::addValue | ( | const QVariant & | value | ) |
Adds a single variant to the statistics calculation.
Calling this method allows variants to be added to the calculation one at a time. For large quantities of variants this may be more efficient then first adding all the variants to a list and calling calculateFromVariants().
value | variant to add |
Definition at line 69 of file qgsstringstatisticalsummary.cpp.
void QgsStringStatisticalSummary::calculate | ( | const QStringList & | values | ) |
Calculates summary statistics for an entire list of strings at once.
values | list of strings |
Definition at line 52 of file qgsstringstatisticalsummary.cpp.
void QgsStringStatisticalSummary::calculateFromVariants | ( | const QVariantList & | values | ) |
Calculates summary statistics for an entire list of variants at once.
Any non-string variants will be ignored.
values | list of variants |
Definition at line 97 of file qgsstringstatisticalsummary.cpp.
|
inline |
Returns the calculated count of values.
Definition at line 138 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the number of distinct string values.
Definition at line 144 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the number of missing (null) string values.
Definition at line 155 of file qgsstringstatisticalsummary.h.
|
static |
Returns the friendly display name for a statistic.
statistic | statistic to return name for |
Definition at line 193 of file qgsstringstatisticalsummary.cpp.
QSet< QString > QgsStringStatisticalSummary::distinctValues | ( | ) | const |
Returns the set of distinct string values.
Definition at line 182 of file qgsstringstatisticalsummary.cpp.
void QgsStringStatisticalSummary::finalize | ( | ) |
Must be called after adding all strings with addString() and before retrieving any calculated string statistics.
Definition at line 78 of file qgsstringstatisticalsummary.cpp.
|
inline |
Returns the most common string.
The majority is the value with most occurrences in the list This is only calculated if Statistic::Majority has been specified in the constructor or via setStatistics. If multiple values match, return the first value relative to the initial values order.
Definition at line 200 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the maximum (non-null) string value.
Definition at line 165 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the maximum length of strings.
Definition at line 175 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the mean length of strings.
Definition at line 180 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the minimum (non-null) string value.
Definition at line 160 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the minimum length of strings.
Definition at line 170 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the least common string.
The minority is the value with least occurrences in the list This is only calculated if Statistic::Minority has been specified in the constructor or via setStatistics. If multiple values match, return the first value relative to the initial values order.
Definition at line 190 of file qgsstringstatisticalsummary.h.
void QgsStringStatisticalSummary::reset | ( | ) |
Resets the calculated values.
Definition at line 37 of file qgsstringstatisticalsummary.cpp.
|
inline |
Sets flags which specify which statistics will be calculated.
Some statistics are always calculated (e.g., count).
stats | flags for statistics to calculate |
Definition at line 66 of file qgsstringstatisticalsummary.h.
QVariant QgsStringStatisticalSummary::statistic | ( | Qgis::StringStatistic | stat | ) | const |
Returns the value of a specified statistic.
stat | statistic to return |
Definition at line 152 of file qgsstringstatisticalsummary.cpp.
|
inline |
Returns flags which specify which statistics will be calculated.
Some statistics are always calculated (e.g., count).
Definition at line 58 of file qgsstringstatisticalsummary.h.