void KNMemoryManager::checkMemoryUsageCollections() { int maxSize = knGlobals.settings()->collCacheSize() * 1024; KNArticleCollection::Ptr c; if (c_ollCacheSize > maxSize) { CollectionItem::List tempList( mColList ); // work on a copy, KNGroup-/Foldermanager will // modify the original list for ( CollectionItem::List::Iterator it = tempList.begin(); it != tempList.end(); ) { if ( c_ollCacheSize <= maxSize ) break; // unloadHeaders() will remove the cache entry and thus invalidate the iterator! c = (*it)->col; ++it; if (c->type() == KNCollection::CTgroup) knGlobals.groupManager()->unloadHeaders( boost::static_pointer_cast<KNGroup>( c ), false ); // *try* to unload else if (c->type() == KNCollection::CTfolder) knGlobals.folderManager()->unloadHeaders( boost::static_pointer_cast<KNFolder>( c ), false ); // *try* to unload } } kDebug(5003) <<"KNMemoryManager::checkMemoryUsageCollections() :" << mColList.count() << "collections in cache => Usage :" << ( c_ollCacheSize*100.0 / maxSize ) << "%"; }
void ImportImages::filter() { int iterations = fileList.length(); QStringList tempList( fileList ); QString str; fileList.clear(); // Sorting through the image list to find those with compatible image formats for (int i = 0; i < iterations; i++) { if (tempList.value(i).endsWith(".tif",Qt::CaseInsensitive) || tempList.value(i).endsWith(".png",Qt::CaseInsensitive) || tempList.value(i).endsWith(".bmp",Qt::CaseInsensitive) || tempList.value(i).endsWith(".jpg",Qt::CaseInsensitive) || tempList.value(i).endsWith(".jpeg",Qt::CaseInsensitive) || tempList.value(i).endsWith(".gif",Qt::CaseInsensitive) || tempList.value(i).endsWith(".pbm",Qt::CaseInsensitive) || tempList.value(i).endsWith(".pgm",Qt::CaseInsensitive) || tempList.value(i).endsWith(".ppm",Qt::CaseInsensitive) || tempList.value(i).endsWith(".xbm",Qt::CaseInsensitive) || tempList.value(i).endsWith(".xpm",Qt::CaseInsensitive) ) { str = dirString; str.append("/"); fileList.append(str.append(tempList.value(i))); } } fileList.sort(); }
/*======================================================================*/ void ImportImages::filter() { int iterations = fileList.length(); QStringList tempList( fileList ); QString str; fileList.clear(); for (int i = 0; i < iterations; i++) { if ( //tempList.value(i).endsWith(".tif",Qt::CaseInsensitive) || //tempList.value(i).endsWith(".png",Qt::CaseInsensitive) || tempList.value(i).endsWith(".bmp",Qt::CaseInsensitive) //tempList.value(i).endsWith(".jpg",Qt::CaseInsensitive) || //tempList.value(i).endsWith(".jpeg",Qt::CaseInsensitive) || //tempList.value(i).endsWith(".gif",Qt::CaseInsensitive) || //tempList.value(i).endsWith(".pbm",Qt::CaseInsensitive) || //tempList.value(i).endsWith(".pgm",Qt::CaseInsensitive) || //tempList.value(i).endsWith(".ppm",Qt::CaseInsensitive) || //tempList.value(i).endsWith(".xbm",Qt::CaseInsensitive) || //tempList.value(i).endsWith(".xpm",Qt::CaseInsensitive) ) { str = dirString; str.append("/"); fileList.append(str.append(tempList.value(i))); } } fileList.sort(); }
QVector<QPair<int, int> > InnerDecklistNode::sort(Qt::SortOrder order) { QVector<QPair<int, int> > result(size()); // Initialize temporary list with contents of current list QVector<QPair<int, AbstractDecklistNode *> > tempList(size()); for (int i = size() - 1; i >= 0; --i) { tempList[i].first = i; tempList[i].second = at(i); } // Sort temporary list compareFunctor cmp(order); qSort(tempList.begin(), tempList.end(), cmp); // Map old indexes to new indexes and // copy temporary list to the current one for (int i = size() - 1; i >= 0; --i) { result[i].first = tempList[i].first; result[i].second = i; replace(i, tempList[i].second); } return result; }
void Util::CaseInsensitiveStringListRemoveElement(QStringList& list, const QString& str) { //Since QStringList::remove is case-Sensitive, we roll our own algorithm for removing. //Could use a single `removeAt` in the `for` if we know list doesn't contain duplicates. QStringList tempList(list); list.clear(); for (int i = 0; i < tempList.count(); i++) if (tempList.at(i).compare(str, Qt::CaseInsensitive) != 0) list.append(tempList.at(i)); }
void postProcessingWaves::readIndices ( const dictionary& indexDict, labelList& indices ) { // Getting the labelList of data set indices if (actionProperties_.lookupOrDefault<Switch>("allDataSets", false)) { labelList tempList( indexDict.lookup("index") ); indices.setSize( tempList.size() ); indices = tempList; } else { labelList tempList( actionProperties_.lookup("indices") ); indices.setSize( tempList.size() ); indices = tempList; } }
/** Adds a scenegraph Entity to this vfcOctree Entity unless max nodes has been reached. If MAX_INITIAL_NODES_BEFORE_SUBDIVISION is reached, subdivision hasn't yet been done and MAX_SUBDIVISION hasn't been reached, subdivision occurs. */ bool PhysicsOctree::AddEntity(Entity * targetEntity) { // Check that it isn't already added! bool exists = entities.Exists(targetEntity); if (exists){ std::cout<<"\nAdding Entity to PhysicsOctree while it already exists!"; assert("Adding Entity to PhysicsOctree while it already exists!" && false); return false; } // If we have children, check if it fits in any of them. if (child[0]) { int result = OUTSIDE; for (int i = 0; i < MAX_CHILDREN; ++i) { result = child[i]->IsEntityInside(targetEntity); switch(result) { case OUTSIDE: // If the Entity is outside, just check next octree-section~ continue; case INTERSECT: // If intersecting, don't do anything. Check all children and handle intersections after this for-loop. break; case INSIDE: // If it is inside, continue down the chain and then return from hierrr. return child[i]->AddEntity(targetEntity); } } // If we arrived here, it's either intersecting or something, so add it to our current children since it can't go further down the tree. entities.Add(targetEntity); // Set pointer for the entity too now targetEntity->physics->octreeNode = this; return true; } /// End of trying to enter it into any of our children // Okay, no spot in children, check if we should subdivide it (if the children aren't already allocated, that is!) if (entities.Size() > MAX_INITIAL_NODES_BEFORE_SUBDIVISION && child[0] == NULL && this->subdivision < MAX_SUBDIVISION){ // Subdivide and then try push all our children down the tree further, so they don't get stuck here without reason. subdivide(); List<Entity*> tempList(entities); entities.Clear(); for (int j = 0; j < tempList.Size(); ++j){ AddEntity(tempList[j]); } // Return if we subdivided, just make sure we try to add our new child to the subdivision too. return AddEntity(targetEntity); } // Alright, children are out, just add it now then. entities.Add(targetEntity); targetEntity->physics->octreeNode = this; return true; }
QStringList libPak::getFoldersAt(const QString &path) { QString newPath(path); newPath.replace("\\", "\\\\"); QStringList tempList(_filenamesOnly.grep(QRegExp("^" + newPath + "\\\\[^\\\\]+\\\\[^\\\\]+$")).gres(QRegExp("^" + newPath + "\\\\([^\\\\]+)\\\\.*"), "\\1")); // Remove duplicates QMap<QString, int> tempMap; QStringList::Iterator it = tempList.end(); while (it != tempList.begin()) { tempMap[*it] = 0; it--; } return tempMap.keys(); }
void KNMemoryManager::checkMemoryUsageArticles() { int maxSize = knGlobals.settings()->artCacheSize() * 1024; if (a_rtCacheSize > maxSize) { ArticleItem::List tempList( mArtList ); // work on a copy, KNArticlemanager will // modify the original list for ( ArticleItem::List::Iterator it = mArtList.begin(); it != mArtList.end(); ) { if ( a_rtCacheSize <= maxSize ) break; // unloadArticle() will remove the cache entry and thus invalidate the iterator! KNArticle::Ptr art = (*it)->art; ++it; knGlobals.articleManager()->unloadArticle( art, false ); // *try* to unload } } kDebug(5003) <<"KNMemoryManager::checkMemoryUsageArticles() :" << mArtList.count() << "articles in cache => Usage :" << ( a_rtCacheSize*100.0 / maxSize ) << "%"; }
bool CSVSettings::View::stringListsMatch ( const QStringList &list1, const QStringList &list2) const { //returns a "sloppy" match, verifying that each list contains all the same //items, though not necessarily in the same order. if (list1.size() != list2.size()) return false; QStringList tempList(list2); //iterate each value in the list, removing one occurrence of the value in //the other list. If no corresponding value is found, test fails foreach (const QString &value, list1) { if (!tempList.contains(value)) return false; tempList.removeOne(value); } return true; }
QStringList SpeechData::parseText(const QString &text, const QCString &appId /*=NULL*/) { // There has to be a better way // kdDebug() << "I'm getting: " << endl << text << " from application " << appId << endl; if (isSsml(text)) { QString tempList(text); return tempList; } // See if app has specified a custom sentence delimiter and use it, otherwise use default. QRegExp sentenceDelimiter; if (sentenceDelimiters.find(appId) != sentenceDelimiters.end()) sentenceDelimiter = QRegExp(sentenceDelimiters[appId]); else sentenceDelimiter = QRegExp("([\\.\\?\\!\\:\\;]\\s)|(\\n *\\n)"); QString temp = text; // Replace spaces, tabs, and formfeeds with a single space. temp.replace(QRegExp("[ \\t\\f]+"), " "); // Replace sentence delimiters with tab. temp.replace(sentenceDelimiter, "\\1\t"); // Replace remaining newlines with spaces. temp.replace("\n"," "); temp.replace("\r"," "); // Remove leading spaces. temp.replace(QRegExp("\\t +"), "\t"); // Remove trailing spaces. temp.replace(QRegExp(" +\\t"), "\t"); // Remove blank lines. temp.replace(QRegExp("\t\t+"),"\t"); // Split into sentences. QStringList tempList = QStringList::split("\t", temp, false); // for ( QStringList::Iterator it = tempList.begin(); it != tempList.end(); ++it ) { // kdDebug() << "'" << *it << "'" << endl; // } return tempList; }
// static helper function to generate one list of disks // (returns an array of ExScratchDiskDrive objects) static ExScratchDiskDrive * genScratchDisks(const NAString &def, Lng32 &numDirs, Generator *generator, const char *defName) { ExScratchDiskDrive *result = NULL; // temporary // numDrives = 0; // return result; // end temporary const char *str = def.data(); if (!str || str[0]=='\0') { numDirs = 0; return result; // fast return if empty NADefaults val } // --------------------------------------------------------------------- // Convert the strings into a temporary list of ExScratchDiskDrive // objects (temporary because we want to make the final list a // contiguous array) // --------------------------------------------------------------------- CollHeap *heap = generator->wHeap(); Space *space = generator->getSpace(); LIST(ExScratchDiskDrive *) tempList(heap); struct stat st; Lng32 nodeNum; char *token,*saveptr = NULL; //save the pointer to this since token will keep changing. char *sep = (char *)":"; token = strtok_r((char *)str,sep,&saveptr); while (token != NULL) { //validate the directory if ((stat(token,&st) != 0 ) && !S_ISDIR(st.st_mode) ) //&& (numDirs > MAX_SCRATCH_LOCATIONS)) { // syntax error in default, issue a warning (not an error) *CmpCommon::diags() << DgSqlCode(2055) << DgString0(def) << DgString1(defName); // don't continue after a syntax error str = NULL; } else { tempList.insert(new(heap) ExScratchDiskDrive( token, strlen(token) )); } token = strtok_r(NULL,sep,&saveptr); } token = NULL; // --------------------------------------------------------------------- // Calculate total generated space needed and allocate it // --------------------------------------------------------------------- numDirs = tempList.entries(); Lng32 allDirNamesLen = 0; char *generatedDirNames = NULL; Int32 i=0; for (; i<numDirs; i++) { allDirNamesLen += str_len(tempList[i]->getDirName())+1; } if (numDirs >0) { result = new(space) ExScratchDiskDrive[numDirs]; generatedDirNames = new(space) char[allDirNamesLen]; } // --------------------------------------------------------------------- // Loop over the temporary list and copy it into the generated space // --------------------------------------------------------------------- for (i=0; i<numDirs; i++) { ExScratchDiskDrive *src = tempList[i]; Lng32 dirNameLen = src->getDirNameLength(); str_cpy_all(generatedDirNames, src->getDirName(), dirNameLen); generatedDirNames[dirNameLen] = 0; result[i].setDirName(generatedDirNames); result[i].setDirNameLength(dirNameLen); generatedDirNames += dirNameLen+1; } return result; }