const T& List<T>::Back () const { if (Empty()) { std::cerr << "** List error: Back() called on empty list\n"; } return *rBegin(); }
void QGalleryTrackerResultSetPrivate::synchronize() { const const_row_iterator rEnd(rCache.values.constEnd(), tableWidth); const const_row_iterator iEnd(iCache.values.constEnd(), tableWidth); const_row_iterator rBegin(rCache.values.constBegin(), tableWidth); const_row_iterator iBegin(iCache.values.constBegin(), tableWidth); const int rStep = qMax(64, rEnd - rBegin) / 16; const int iStep = qMax(64, iEnd - iBegin) / 16; for (bool equal = true; equal && rBegin != rEnd && iBegin != iEnd; ) { bool changed = false; do { // Skip over identical rows. if ((equal = rBegin.isEqual(iBegin, identityWidth)) && !(changed = !rBegin.isEqual(iBegin, identityWidth, tableWidth))) { ++rBegin; ++iBegin; } else { break; } } while (iBegin != rEnd && iBegin != iEnd); if (changed) { const_row_iterator rIt = rBegin; const_row_iterator iIt = iBegin; do { // Skip over rows with equal IDs but different values. if ((equal = rIt.isEqual(iIt, identityWidth)) && rIt.isEqual(iIt, identityWidth, tableWidth)) { ++rIt; ++iIt; } else { ++rIt; ++iIt; break; } } while (rIt != rEnd && iIt != iEnd); const int rIndex = rCacheIndex(rBegin); const int iIndex = iCacheIndex(iBegin); const int count = iIt - iBegin; postSyncEvent(SyncEvent::updateEvent(rIndex, iIndex, count)); rBegin = rIt; iBegin = iIt; continue; } else if (equal) { postSyncEvent(SyncEvent::finishEvent(rCacheIndex(rBegin), iCacheIndex(iBegin))); return; } const_row_iterator rOuterEnd = rBegin + ((((rEnd - rBegin) + iStep - 1) / rStep) * rStep); const_row_iterator iOuterEnd = iBegin + ((((iEnd - iBegin) + iStep - 1) / iStep) * iStep); const_row_iterator rInnerEnd = qMin(rBegin + rStep * 2, rEnd); const_row_iterator iInnerEnd = qMin(iBegin + iStep * 2, iEnd); for (const_row_iterator rOuter = rBegin, iOuter = iBegin; !equal && rOuter != rOuterEnd && iOuter != iOuterEnd; rOuter += rStep, iOuter += iStep) { for (const_row_iterator rInner = rBegin, iInner = iBegin; rInner != rInnerEnd && iInner != iInnerEnd; ++rInner, ++iInner) { if ((equal = rInner.isEqual(iOuter, identityWidth))) { const_row_iterator rIt; const_row_iterator iIt; do { rIt = rInner; iIt = iOuter; } while (rInner-- != rBegin && iOuter-- != iBegin && rInner.isEqual(iOuter, identityWidth)); const int rIndex = rCacheIndex(rOuter); const int iIndex = iCacheIndex(iBegin); const int rCount = rIt - rBegin; const int iCount = iIt - iBegin; postSyncEvent(SyncEvent::replaceEvent(rIndex, rCount, iIndex, iCount)); rBegin = rIt; iBegin = iIt; break; } else if ((equal = iInner.isEqual(rOuter, identityWidth))) { const_row_iterator rIt; const_row_iterator iIt; do { rIt = rOuter; iIt = iInner; } while (iInner-- != iBegin && rOuter-- != rBegin && iInner.isEqual(rOuter, identityWidth)); const int rIndex = rCacheIndex(rBegin); const int iIndex = iCacheIndex(iOuter); const int rCount = rIt - rBegin; const int iCount = iIt - iBegin; postSyncEvent(SyncEvent::replaceEvent(rIndex, rCount, iIndex, iCount)); rBegin = rIt; iBegin = iIt; break; } } } } postSyncEvent(SyncEvent::finishEvent(rCacheIndex(rBegin), iCacheIndex(iBegin))); }