void CEpg::Sort(void) { CSingleLock lock(m_critSection); if (m_bInhibitSorting) return; /* sort the EPG */ sort(begin(), end(), sortEPGbyDate()); /* reset the previous and next pointers on each tag */ int iTagAmount = size(); for (int ptr = 0; ptr < iTagAmount; ptr++) { CEpgInfoTag *tag = at(ptr); if (ptr == 0) { tag->SetPreviousEvent(NULL); } if (ptr > 0) { CEpgInfoTag *previousTag = at(ptr-1); previousTag->SetNextEvent(tag); tag->SetPreviousEvent(previousTag); } if (ptr == iTagAmount - 1) { tag->SetNextEvent(NULL); } } }
void CEpg::UpdatePreviousAndNextPointers(void) { int iTagAmount = size(); for (int ptr = 0; ptr < iTagAmount; ptr++) { CEpgInfoTag *tag = at(ptr); if (ptr == 0) { /* first tag has no previous event */ tag->SetPreviousEvent(NULL); } else { /* set the next event in the previous tag */ CEpgInfoTag *previousTag = at(ptr-1); previousTag->SetNextEvent(tag); /* set the previous event in this tag */ tag->SetPreviousEvent(previousTag); } if (ptr == iTagAmount - 1) { /* ensure that the next event for the last tag is set to NULL */ tag->SetNextEvent(NULL); } } }