QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
Calculator for summary statistics and aggregates for a list of strings. More...
#include <qgsstringstatisticalsummary.h>
Public Types | |
enum | Statistic { Count = 1, CountDistinct = 2, CountMissing = 4, Min = 8, Max = 16, MinimumLength = 32, MaximumLength = 64, All = Count | CountDistinct | CountMissing | Min | Max } |
Enumeration of flags that specify statistics to be calculated. More... | |
Public Member Functions | |
QgsStringStatisticalSummary (const QgsStringStatisticalSummary::Statistics &stats=All) | |
Constructor for QgsStringStatistics. More... | |
void | addString (const QString &string) |
Adds a single string to the statistics calculation. More... | |
void | addValue (const QVariant &value) |
Adds a single variant to the statistics calculation. More... | |
void | calculate (const QStringList &values) |
Calculates summary statistics for an entire list of strings at once. More... | |
void | calculateFromVariants (const QVariantList &values) |
Calculates summary statistics for an entire list of variants at once. More... | |
int | count () const |
Returns the calculated count of values. More... | |
int | countDistinct () const |
Returns the number of distinct string values. More... | |
int | countMissing () const |
Returns the number of missing (null) string values. More... | |
QSet< QString > | distinctValues () const |
Returns the set of distinct string values. More... | |
void | finalize () |
Must be called after adding all strings with addString() and before retrieving any calculated string statistics. More... | |
QString | max () const |
Returns the maximum (non-null) string value. More... | |
int | maxLength () const |
Returns the maximum length of strings. More... | |
QString | min () const |
Returns the minimum (non-null) string value. More... | |
int | minLength () const |
Returns the minimum length of strings. More... | |
void | reset () |
Resets the calculated values. More... | |
void | setStatistics (const Statistics &stats) |
Sets flags which specify which statistics will be calculated. More... | |
QVariant | statistic (Statistic stat) const |
Returns the value of a specified statistic. More... | |
Statistics | statistics () const |
Returns flags which specify which statistics will be calculated. More... | |
Static Public Member Functions | |
static QString | displayName (Statistic statistic) |
Returns the friendly display name for a statistic. More... | |
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 40 of file qgsstringstatisticalsummary.h.
Enumeration of flags that specify statistics to be calculated.
Definition at line 45 of file qgsstringstatisticalsummary.h.
QgsStringStatisticalSummary::QgsStringStatisticalSummary | ( | const QgsStringStatisticalSummary::Statistics & | stats = All | ) |
Constructor for QgsStringStatistics.
stats | flags for statistics to calculate |
Definition at line 30 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 58 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 63 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 47 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 78 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 143 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the number of missing (null) string values.
Definition at line 152 of file qgsstringstatisticalsummary.h.
|
static |
Returns the friendly display name for a statistic.
statistic | statistic to return name for |
Definition at line 152 of file qgsstringstatisticalsummary.cpp.
Returns the set of distinct string values.
Definition at line 148 of file qgsstringstatisticalsummary.h.
void QgsStringStatisticalSummary::finalize | ( | ) |
Must be called after adding all strings with addString() and before retrieving any calculated string statistics.
Definition at line 72 of file qgsstringstatisticalsummary.cpp.
|
inline |
Returns the maximum (non-null) string value.
Definition at line 160 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the maximum length of strings.
Definition at line 168 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the minimum (non-null) string value.
Definition at line 156 of file qgsstringstatisticalsummary.h.
|
inline |
Returns the minimum length of strings.
Definition at line 164 of file qgsstringstatisticalsummary.h.
void QgsStringStatisticalSummary::reset | ( | ) |
Resets the calculated values.
Definition at line 36 of file qgsstringstatisticalsummary.cpp.
|
inline |
Sets flags which specify which statistics will be calculated.
Some statistics are always calculated (eg count).
stats | flags for statistics to calculate |
Definition at line 74 of file qgsstringstatisticalsummary.h.
QVariant QgsStringStatisticalSummary::statistic | ( | QgsStringStatisticalSummary::Statistic | stat | ) | const |
Returns the value of a specified statistic.
stat | statistic to return |
Definition at line 128 of file qgsstringstatisticalsummary.cpp.
|
inline |
Returns flags which specify which statistics will be calculated.
Some statistics are always calculated (eg count).
Definition at line 67 of file qgsstringstatisticalsummary.h.