void nsFileView::SortInternal() { SortArray(mDirList); SortArray(mFilteredFiles); if (mReverseSort) { ReverseArray(mDirList); ReverseArray(mFilteredFiles); } }
NS_IMETHODIMP nsFileView::SetShowOnlyDirectories(bool aOnlyDirs) { if (aOnlyDirs == mDirectoryFilter) return NS_OK; mDirectoryFilter = aOnlyDirs; PRUint32 dirCount; mDirList->Count(&dirCount); if (mDirectoryFilter) { PRInt32 rowDiff = mTotalRows - dirCount; mFilteredFiles->Clear(); mTotalRows = dirCount; if (mTree) mTree->RowCountChanged(mTotalRows, -rowDiff); } else { // Run the filter again to get the file list back FilterFiles(); SortArray(mFilteredFiles); if (mReverseSort) ReverseArray(mFilteredFiles); if (mTree) mTree->RowCountChanged(dirCount, mTotalRows - dirCount); } return NS_OK; }
NS_IMETHODIMP nsFileView::Sort(PRInt16 aSortType, bool aReverseSort) { if (aSortType == mSortType) { if (aReverseSort == mReverseSort) return NS_OK; mReverseSort = aReverseSort; ReverseArray(mDirList); ReverseArray(mFilteredFiles); } else { mSortType = aSortType; mReverseSort = aReverseSort; SortInternal(); } if (mTree) mTree->Invalidate(); return NS_OK; }
int main() { printf("Enter n, a, b:"); int n,a,b; scanf("%d %d %d", &n,&a,&b); double *array = (char *) malloc(n * sizeof(char)); for(int i = 0; i < n; i++) printf("%f ", array[i]); printf("\n"); ReverseArray(array, n); for(int i = 0; i < n; i++) printf("%f ", array[i]); printf("\n"); free(array); }
int main() { int n,i,a,b; printf("Enter the number: "); scanf("%d", &n); double *ar; ar = (double *)malloc(sizeof(double)*n); for(i=0;i<n;i++) { printf("Enter next element of array: "); scanf("%lf", &ar[i]); } ReverseArray(n,ar); for(i=0;i<n;i++) printf("%lf ",ar[i]); free(ar); return 0; }
NS_IMETHODIMP nsFileView::SetFilter(const nsAString& aFilterString) { PRUint32 filterCount = mCurrentFilters.Length(); for (PRUint32 i = 0; i < filterCount; ++i) NS_Free(mCurrentFilters[i]); mCurrentFilters.Clear(); nsAString::const_iterator start, iter, end; aFilterString.BeginReading(iter); aFilterString.EndReading(end); while (true) { // skip over delimiters while (iter != end && (*iter == ';' || *iter == ' ')) ++iter; if (iter == end) break; start = iter; // start of a filter // we know this is neither ';' nor ' ', skip to next char ++iter; // find next delimiter or end of string while (iter != end && (*iter != ';' && *iter != ' ')) ++iter; PRUnichar* filter = ToNewUnicode(Substring(start, iter)); if (!filter) return NS_ERROR_OUT_OF_MEMORY; if (!mCurrentFilters.AppendElement(filter)) { NS_Free(filter); return NS_ERROR_OUT_OF_MEMORY; } if (iter == end) break; ++iter; // we know this is either ';' or ' ', skip to next char } if (mTree) { mTree->BeginUpdateBatch(); PRUint32 count; mDirList->Count(&count); mTree->RowCountChanged(count, count - mTotalRows); } mFilteredFiles->Clear(); FilterFiles(); SortArray(mFilteredFiles); if (mReverseSort) ReverseArray(mFilteredFiles); if (mTree) mTree->EndUpdateBatch(); return NS_OK; }