6 #ifndef ACE_TIME_ZONE_SORTER_BY_NAME_H
7 #define ACE_TIME_ZONE_SORTER_BY_NAME_H
9 #include <AceSorting.h>
10 #include "ZoneManager.h"
20 template <
typename ZM>
28 mZoneManager(zoneManager)
36 for (uint16_t i = 0; i < size; i++) {
43 ace_sorting::shellSortKnuth(indexes, size,
44 [
this](uint16_t indexA, uint16_t indexB) ->
bool {
45 auto za = this->mZoneManager.getZoneForIndex(indexA);
46 auto zb = this->mZoneManager.getZoneForIndex(indexB);
47 return za.kname().compareTo(zb.kname()) < 0;
53 void sortIds(uint32_t ids[], uint16_t size)
const {
54 ace_sorting::shellSortKnuth(ids, size,
55 [
this](uint32_t a, uint32_t b) ->
bool {
56 uint16_t indexA = this->mZoneManager.indexForZoneId(a);
57 uint16_t indexB = this->mZoneManager.indexForZoneId(b);
58 auto za = this->mZoneManager.getZoneForIndex(indexA);
59 auto zb = this->mZoneManager.getZoneForIndex(indexB);
60 return za.kname().compareTo(zb.kname()) < 0;
66 void sortNames(
const char* names[], uint16_t size)
const {
67 ace_sorting::shellSortKnuth(names, size,
68 [
this](
const char* a,
const char* b) ->
bool {
69 uint16_t indexA = this->mZoneManager.indexForZoneName(a);
70 uint16_t indexB = this->mZoneManager.indexForZoneName(b);
71 auto za = this->mZoneManager.getZoneForIndex(indexA);
72 auto zb = this->mZoneManager.getZoneForIndex(indexB);
73 return za.kname().compareTo(zb.kname()) < 0;
84 const ZM& mZoneManager;
ZoneSorterByName, templatized on BasicZoneManager or ExtendedZoneManager.
ZoneSorterByName(const ZM &zoneManager)
Constructor.
void sortNames(const char *names[], uint16_t size) const
Sort the given array of zone names by UTC offset, then by name.
void sortIndexes(uint16_t indexes[], uint16_t size) const
Sort the given array of indexes by UTC offset, then by name.
void sortIds(uint32_t ids[], uint16_t size) const
Sort the given array of zone ids by UTC offset, then by name.
void fillIndexes(uint16_t indexes[], uint16_t size) const
Fill the given array of indexes with index from [0, size).