Untitled
Anonymous
plain_text
03/02/2026 8:29 AM
3.0 KB
16
Indexable
// checks if 5 consecutive years of records are present (if not softdelete = True)
void CheckConsecutiveYears(vector<Station>& stations, vector<Recording>& recordings)
{
for (size_t stationIndex = 0; stationIndex < stations.size(); stationIndex++)
{
int yearCount = 0;
int lastYear = 0;
bool foundConsecutive = false;
size_t startIndex = stations.at(stationIndex).recordsStartIndex;
size_t endIndex = startIndex + stations.at(stationIndex).recordsOffset;
for (size_t recordIndex = startIndex; recordIndex < endIndex; recordIndex++)
{
int currentYear = recordings.at(recordIndex).year;
if (lastYear == 0)
{
yearCount = 1;
}
else if (currentYear == lastYear + 1)
{
yearCount++;
}
else if (currentYear != lastYear)
{
yearCount = 1;
}
lastYear = currentYear;
if (yearCount >= 5)
{
foundConsecutive = true;
break;
}
}
if (foundConsecutive == false)
{
stations.at(stationIndex).softDeleted = true;
}
}
}
void CheckStationsReportCount(vector<Station>& stations, vector<Recording>& recordings)
{
for (size_t stationIndex = 0; stationIndex < stations.size(); stationIndex++)
{
size_t yearCount = 0;
size_t currentYear = 0;
size_t startIndex = stations.at(stationIndex).recordsStartIndex;
size_t endIndex = startIndex + stations.at(stationIndex).recordsOffset;
if (!stations.at(stationIndex).softDeleted)
{
for (size_t i = startIndex; i < endIndex; i++)
{
if (recordings.at(i).year != currentYear)
{
yearCount++;
}
currentYear = recordings.at(i).year;
}
if (yearCount > 0 && ((endIndex - startIndex) / yearCount) <= 100)
{
stations.at(stationIndex).softDeleted = true;
}
}
yearCount = 0;
}
}Editor is loading...
Leave a Comment