Boolean XFE_AddrBookView::isCommandSelected(CommandType cmd, void */* calldata */, XFE_CommandInfo* /* i */) { /* * XP_Bool AB_GetPaneSortedAscending(ABPane * pABookPane); * ABID AB_GetPaneSortedBy(ABPane * pABookPane); */ ABID sortType = 0; if (cmd == xfeCmdABByType) sortType = ABTypeEntry; else if (cmd == xfeCmdABByName) sortType = ABFullName; else if (cmd == xfeCmdABByEmailAddress) sortType = ABEmailAddress; else if (cmd == xfeCmdABByCompany) sortType = ABCompany; else if (cmd == xfeCmdABByLocality) sortType = ABLocality; else if (cmd == xfeCmdABByNickName) sortType = ABNickname; if (sortType > 0) { if (sortType == getSortType()) return True; return False; }/* if */ else if ((cmd == xfeCmdSortAscending && isAscending())|| (cmd == xfeCmdSortDescending && !isAscending())) return True; return False; }
/* main execution of program */ int main (){ int last = 0; /* index tracking */ int list[SIZE] = {}; /* initialize array to 0's regardless of default fill values */ fillArray(list, TRUE); /* set up random function feed, set up only once per program */ srand (time(NULL)); /* fill array with random numbers */ fillArray(list, FALSE); /* print list before is sorted */ printf("list of values before sorting\n"); printArray(list); if (isAscending(list, SIZE)) { /* do nothing, if you want ascending array */ }else if(isDescending(list, SIZE)) { /* if it is descending order, reverse the array */ reverse(list, 0, SIZE - 1); } else { /* sort list in ascending order */ last = SIZE - 1; selectionSort(list, last); } /* print list after is sorted */ printf("list of values after sorting\n"); printArray(list); return 0; } /* end main */
void insert_01(node *pnode, int v){ // assume ascending order if(pnode == NULL) return; if(pnode->next == pnode){ // only one node in list insertNode(pnode, pnode, v); return; } bool ascending = isAscending(pnode); node *curr = pnode, *post = pnode->next; do{ if(ascending){ if((curr->val < v && v < post->val) || (curr->val > post->val && (curr->val < v || v < post->val))){ insertNode(curr, post, v); return; } }else{ if((curr->val > v && v > post->val) || (curr->val < post->val && (curr->val > v || v > post->val))){ insertNode(curr, post, v); return; } } curr = post; post = post->next; }while(curr != pnode); insertNode(curr, post, v); return; }
QXmlStreamWriter& TableSortField::write(QXmlStreamWriter& writer) const { TypeMapper mapper; writer.writeStartElement("TableSortField"); writer.writeAttribute("Name", m_fieldName); writer.writeAttribute("Index", QString("%1").arg(m_fieldIndex)); writer.writeAttribute("CaseSensitive", m_comparer != nullptr && m_comparer->caseSensitivity() == Qt::CaseSensitive ? "True" : "False"); writer.writeAttribute("Type", mapper.getMetaName(m_MetaType)); writer.writeAttribute(s_Ascending, isAscending() ? "True" : "False"); writer.writeEndElement(); return writer; }
// LCOV_EXCL_START :dd NABoolean NAColumnArray::operator==(const NAColumnArray &other) const { if (entries() != other.entries()) return FALSE; for (CollIndex i=0;i<entries();i++) { if (NOT (*at(i)== *other.at(i))) return FALSE; if (NOT (isAscending(i) == other.isAscending(i))) return FALSE; } return TRUE; }
void MailListView::writeConfig( QSettings *conf) { QString temp; if (!singleColumnMode()) { for (int x = 0; x < columnCount(); x++) { temp.setNum(x); conf->setValue("querycol" + temp, columnWidth(x) ); conf->setValue("querycollabelpos" + temp, labelPos(x) ); } conf->setValue( "querycolsort", sortedColumn() ); conf->setValue( "querycolsortascending", isAscending() ); conf->setValue( "arrivaldate", arrivalDate() ); conf->setValue( "showheader", horizontalHeader()->isHidden() ); } }
int leftScanlineIntersections(const TQuadratic &q, double t0, double t1, bool &ascending) { const TPointD &p0 = q.getP0(), &p1 = q.getP1(), &p2 = q.getP2(); double y1_y0 = y(p1) - y(p0), accel = y(p2) - y(p1) - y1_y0; // Fallback to segment case whenever we have too flat quads if (std::fabs(accel) < m_tol) return leftScanlineIntersections(TSegment(q.getPoint(t0), q.getPoint(t1)), ascending); // Calculate new ascension int ascends = isAscending(q, t1, t0 < t1); bool wasAscending = ascending; ascending = (ascends > 0) ? true : (ascends < 0) ? false : (wasAscending = !ascending, ascending); // Couples with the cusps check below // In case the y coords are not in range, quit int solIdx[2]; if (!areInYRange(q, t0, t1, solIdx)) return 0; // Identify coordinates for which q(t) == y double poly[3] = {y(p0) - m_y, 2.0 * y1_y0, accel}, s[2]; int sCount = tcg::poly_ops::solve_2(poly, s); // Tolerance dealt at the first bailout above if (sCount == 2) { // Calculate result int result = 0; if (solIdx[0] >= 0) { result += int(getX(q, s[solIdx[0]]) < m_x && (getY(q, t0) != m_y || ascending == wasAscending)); // Cusp check } if (solIdx[1] >= 0) result += int(getX(q, s[solIdx[1]]) < m_x); return result; } return (assert(sCount == 0), 0); // Should never happen, since m_y is in range. If it ever happens, // it must be close to the extremal - so quit with no intersections. }
bool isSorted(int n, int array[n]) { return (isAscending(n, array) || isDescending(n, array)); }