QList<Qt::PenStyle> AttributeManager::penStyleListOf( const QString& attribute, BasicElement* element ) const { QList<Qt::PenStyle> penStyleList; QStringList tmpList = findValue( attribute, element ).split( " " ); foreach( QString tmp, tmpList ) penStyleList << parsePenStyle( tmp ); return penStyleList; }
bool Bundle::fillDouble(const char* key, double& value) const { List<KeyValuePair>::const_iterator itr = findValue(key); if (itr != mKeyValuePairs->end()) { if (itr->value->getType() == Variant::Double) { value = itr->value->getFloat(); return true; } else { return false; } } return false; }
bool Bundle::fillString(const char* key, sp<String>& string) const { List<KeyValuePair>::const_iterator itr = findValue(key); if (itr != mKeyValuePairs->end()) { if (itr->value->getType() == Variant::CharString) { string = itr->value->getString(); return true; } else { return false; } } return false; }
bool Bundle::fillUInt64(const char* key, uint64_t& value) const { List<KeyValuePair>::const_iterator itr = findValue(key); if (itr != mKeyValuePairs->end()) { if (itr->value->getType() == Variant::UInt64) { value = itr->value->getUInt64(); return true; } else { return false; } } return false; }
HttpConnectionMapEntry* HttpConnectionMap::getPersistentConnection(const Url& url, OsConnectionSocket*& socket) { UtlString keyString; socket = NULL; getPersistentUriKey(url, keyString); HttpConnectionMapEntry* pEntry; { // table lock scope OsLock lock(mLock); pEntry = dynamic_cast<HttpConnectionMapEntry*>(findValue(&keyString)); if (!pEntry) { // Now create a new one pEntry = new HttpConnectionMapEntry("ConnectionMapEntry-%d"); if (pEntry) { if (insertKeyAndValue(new UtlString(keyString.data()), pEntry) != NULL) { OsSysLog::add(FAC_HTTP, PRI_DEBUG, "HttpConnectionMap::getPersistentConnection " "- Adding %s for %s", pEntry->data(), keyString.data()); } else { OsSysLog::add(FAC_HTTP, PRI_ERR, "HttpConnectionMap::getPersistentConnection " "- adding %s (entry %s) failed)", keyString.data(), pEntry->data()); delete pEntry; pEntry = NULL; } } } } // end of table lock if (pEntry) { pEntry->mLock.acquire(); socket = pEntry->mpSocket; pEntry->mbInUse = true; OsSysLog::add(FAC_HTTP, PRI_DEBUG, "HttpConnectionMap::getPersistentConnection - Found %s for %s, socket %p", pEntry->data(), keyString.data(), socket); } return pEntry; }
bool PTGraph::merge(PTGraph& from) { bool modified = false; // first, creating missed nodes for (auto theirnode : from.nodes) { Value *v = theirnode->getValue(); if (!findValue(v, theirnode->isLocation())) { modified |= (addNode(v, theirnode->isLocation()) != NULL); } } // then we could add missing edges for (auto theirnode : from.nodes) { PTNode* mynode = findValue(theirnode->getValue(), theirnode->isLocation()); assert(mynode && "all missed nodes should be created"); for (auto neiberhood : theirnode->next) { //errs() << "mynode: " << *mynode << "\n"; //errs() << "neiberhood: " << *neiberhood << "\n"; modified |= addEdge(mynode, findValue(neiberhood->getValue(), neiberhood->isLocation())); } } return modified; }
//try coloring the graph using dfs // mode 0, simple dfs // mode 1, dfs with forward checking // mode 2, dfs with most constrained value bool dfs(int u, int color, int n_color, int mode) { adj_list adjacents = graph[u].head -> next; int i, next_var; bool r; nodes++; graph[u].color = color; n_color++; //simple checking if(mode == 0 && !checkVertices(u)) { graph[u].color = -1;//uncolor it return false; } //check if colored every vertex already if(n_color == n) return true; //forward checking else if(mode > 0) { for(adjacents = graph[u].head -> next; adjacents != NULL; adjacents = adjacents -> next) { if(graph[adjacents -> index].restrictions[color] == 0) graph[adjacents -> index].size--; graph[adjacents -> index].restrictions[color]++; } } //branch to next node next_var = findValue(mode); //no possible variable if(next_var == -1) return false; for(i = 0; i < k; i++) { if(graph[next_var].restrictions[i] == 0 && dfs(next_var, i, n_color, mode)) return true; } //reverse forward checking if(mode > 0) { for(adjacents = graph[u].head -> next; adjacents != NULL; adjacents = adjacents -> next) { graph[adjacents -> index].restrictions[color]--; if(graph[adjacents -> index].restrictions[color] == 0) graph[adjacents -> index].size++; } } return false; }
int FindValueOperation::execute() const { Q_ASSERT(!m_values.isEmpty()); QVariantMap map = load(m_file); foreach (const QVariant &v, m_values) { const QStringList result = findValue(map, v); foreach (const QString &r, result) std::cout << qPrintable(r) << std::endl; } return 0; }
int main(void) { int num; int i, t; scanf("%d", &t); while(t--) { scanf("%d", &num); if(fiboTable[fiboLen] <= num) { fiboLen = makeFiboTable(num); } findValue(num); putchar('\n'); } }
/* sibal gi ga mak hee ne zz */ void findValue(int num) { int i; if(num == 0) { return; } for(i=1; i<=fiboLen; i++) { if(fiboTable[i] > num) { findValue(num - fiboTable[i-1]); printf("%d ", fiboTable[i-1]); break; } } }
void SipXHandleMap::dump() { UtlHashMapIterator itor(*this) ; UtlInt* pKey ; UtlVoidPtr* pValue ; while ((pKey = (UtlInt*) itor())) { pValue = (UtlVoidPtr*) findValue(pKey) ; printf("\tkey=%08X, value=%p\n", pKey->getValue(), pValue ? pValue->getValue() : 0) ; } }
bool rapidJsonWrap::asBoolean(const std::string &strKey) { rapidjson::Value *pVal = findValue(strKey); if(!pVal) return false; if(pVal->IsBool()) pVal->GetBool(); else if(pVal->IsString()) return std::strtol(pVal->GetString(), NULL, 10) != 0; else if(pVal->IsUint()) return pVal->GetUint() != 0; else if(pVal->IsInt64()) return pVal->GetInt64() != 0; else if(pVal->IsUint64()) return pVal->GetUint64() != 0; else if(pVal->IsNull()) return 0; else JSON_EXCEPT(BEJsonCodeTypeError); return false; }
/* Puts the given variable name and its computed result into the list of environment variables. */ void environment::setValue (char * n, constant * value) { variable * var = findValue (n); if (var != NULL) { // replace variable delete var->getValue (); var->setValue (new constant (*value)); } else { // create new variable var = new variable (n); var->setValue (new constant (*value)); addVariable (var); } }
TEST(AnimationKeyframeEffectModel, MultipleProperties) { AnimatableValueKeyframeVector keyframes(2); keyframes[0] = AnimatableValueKeyframe::create(); keyframes[0]->setOffset(0.0); keyframes[0]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(3.0).get()); keyframes[0]->setPropertyValue(CSSPropertyRight, unknownAnimatableValue(4.0).get()); keyframes[1] = AnimatableValueKeyframe::create(); keyframes[1]->setOffset(1.0); keyframes[1]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(5.0).get()); keyframes[1]->setPropertyValue(CSSPropertyRight, unknownAnimatableValue(6.0).get()); AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectModel::create(keyframes); Vector<RefPtr<Interpolation>> values; effect->sample(0, 0.6, duration, values); EXPECT_EQ(2UL, values.size()); Interpolation* leftValue = findValue(values, CSSPropertyLeft); ASSERT_TRUE(leftValue); expectDoubleValue(5.0, leftValue); Interpolation* rightValue = findValue(values, CSSPropertyRight); ASSERT_TRUE(rightValue); expectDoubleValue(6.0, rightValue); }
int fSettings::appendValue(QVariant fValue, QString array, QString key, int unique) { if((!unique)||(findValue(fValue,array,key)==-1)) { int size=beginReadArray(array); endArray(); beginWriteArray(array); setArrayIndex(size); setValue(key, fValue); endArray(); return 1; } else return 0; }
int flib_ini_get_str_opt(flib_ini *ini, char **outVar, const char *key, const char *def) { int result = INI_ERROR_OTHER; if(!log_badargs_if4(ini==NULL, ini->currentSection==NULL, outVar==NULL, key==NULL)) { const char *value = findValue(ini->inidict, ini->currentSection, key); if(!value) { value = def; } char *valueDup = flib_strdupnull(value); if(valueDup || !def) { *outVar = valueDup; result = 0; } } return result; }
QStringList FindValueOperation::findValue(const QVariant &in, const QVariant &value, const QString &prefix) { QStringList result; if (in.type() == value.type() && in == value) { result << prefix; } else if (in.type() == QVariant::Map) { const QVariantMap map = in.toMap(); for (QVariantMap::const_iterator i = map.begin(); i != map.end(); ++i) { QString pfx = prefix; if (!pfx.isEmpty()) pfx.append(QLatin1Char('/')); pfx.append(i.key()); result.append(findValue(i.value(), value, pfx)); } } else if (in.type() == QVariant::List) { QVariantList list = in.toList(); for (int pos = 0; pos < list.count(); ++pos) { QString pfx = prefix + QLatin1Char('[') + QString::number(pos) + QLatin1Char(']'); result.append(findValue(list.at(pos), value, pfx)); } } return result; }
void SettingsSerializer::setValue(const QString &key, const QVariant &value) { Value* v = findValue(key); if (v) { v->value = value; } else { Value nv{group, array, arrayIndex, key, value}; if (array >= 0) arrays[array].values.append(values.size()); values.append(nv); } }
double rapidJsonWrap::asDouble(const std::string &strKey) { rapidjson::Value *pVal = findValue(strKey); if(!pVal) return 0; if(pVal->IsDouble()) return pVal->GetDouble(); else if(pVal->IsString()) return std::strtod(pVal->GetString(), NULL); else if(pVal->IsBool()) return pVal->GetBool(); else if(pVal->IsInt()) return pVal->GetInt(); else if(pVal->IsUint()) return pVal->GetUint(); else if(pVal->IsInt64()) return pVal->GetInt64(); else if(pVal->IsUint64()) return pVal->GetUint64(); else if(pVal->IsNull()) return 0.0; else JSON_EXCEPT(BEJsonCodeTypeError); return 0.0; }
const char* ED_getStringFromXML(void* _xml, const char* varName) { XMLFile* xml = (XMLFile*)_xml; if (xml != NULL) { XmlNodeRef root = xml->root; char* token = findValue(&root, varName, xml->fileName); if (token != NULL) { char* ret = ModelicaAllocateString(strlen(token)); strcpy(ret, token); return (const char*)ret; } else { ModelicaFormatError("Error in line %i when reading value from file \"%s\"\n", XmlNode_getLine(root), xml->fileName); } } return ""; }
int CsvUtil::findValueInWithLine(const std::string &rSValue, const int &rIValueCol, const std::string &rSCsvFilePath) { auto iRowCount = std::get<1>(getFileRowColNum(rSCsvFilePath)); auto ret = -1; std::string findValue(rSValue); for (int iRow = 0; iRow < iRowCount; ++iRow) { std::string tmpValue = getText(iRow, rIValueCol, rSCsvFilePath); if (findValue == tmpValue) { ret = iRow; break; } } return ret; }
const void* SipXHandleMap::findHandle(SIPXHANDLE handle) { lock() ; const void* pRC = NULL ; UtlInt key(handle) ; UtlVoidPtr* pValue ; pValue = (UtlVoidPtr*) findValue(&key) ; if (pValue != NULL) { pRC = pValue->getValue() ; } unlock() ; return pRC ; }
MpAlsa* MpAlsaContainer::getALSADeviceWrapper(const UtlString& ossdev) { OsLock lock(mMutex); MpAlsa *pDev; UtlString* pName; pDev = static_cast<MpAlsa*>(findValue(&ossdev)); if (pDev == NULL) { pName = new UtlString(ossdev); pDev = new MpAlsa; insertKeyAndValue(pName, pDev); } return pDev; }
void SipXHandleMap::dumpCalls() { UtlHashMapIterator itor(*this) ; UtlInt* pKey ; UtlVoidPtr* pValue ; while ((pKey = (UtlInt*) itor())) { pValue = (UtlVoidPtr*) findValue(pKey) ; assert(pValue != NULL); SIPX_CALL_DATA* pCallData = (SIPX_CALL_DATA*)pValue->getValue(); printf("\tkey=%08d, value=0x%p, CallId=%s SessionCallId=%s\n", pKey->getValue(), pValue->getValue(), pCallData->callId?pCallData->callId->data():"NULL", pCallData->sessionCallId?pCallData->sessionCallId->data():"NULL") ; } }
bool removeFromGoalList(uint8_t nodeNum) { int8_t i = findValue(goalList, goalListSize, nodeNum); if (i == -1) { numUnreachedGoals--; numKnownGoals++; return false; } for (; i < goalListSize - 1; i++) { goalList[i] = goalList[i + 1]; } goalListSize--; numUnreachedGoals--; return true; }
PTNode* PTGraph::addNode(Value *v, bool isLocation) { PTNode* node = findValue(v, isLocation); if (node) return NULL; node = new PTNode(v, isLocation); nodes.push_back(node); // GlobalValue, AllocaInst, malloc always is // pointer and placeholder. CallSite CS(v); bool isMalloc = (!!CS) && CS.getCalledFunction()->getName() == "malloc"; if (isa<GlobalValue>(v) || isa<AllocaInst>(v) || isMalloc) { PTNode* pnode = new PTNode(v, !isLocation); nodes.push_back(pnode); if (!isLocation) addEdge(node, pnode); else addEdge(pnode, node); } return node; }
int ED_getIntFromXML(void* _xml, const char* varName) { int ret = 0; XMLFile* xml = (XMLFile*)_xml; if (xml != NULL) { XmlNodeRef root = xml->root; char* token = findValue(&root, varName, xml->fileName); if (token != NULL) { if (ED_strtoi(token, xml->loc, &ret)) { ModelicaFormatError("Error in line %i when reading int value \"%s\" from file \"%s\"\n", XmlNode_getLine(root), token, xml->fileName); } } else { ModelicaFormatError("Error in line %i when reading int value from file \"%s\"\n", XmlNode_getLine(root), xml->fileName); } } return ret; }
// Destructor MpAlsaContainer::~MpAlsaContainer() { for (;;) { UtlHashMapIterator itor(*this); UtlString* pDevName; if ((pDevName = static_cast<UtlString*>(itor()))) { MpAlsa *pDev = static_cast<MpAlsa*>(findValue(pDevName)); if (pDev) { excludeFromContainer(pDev); } } else { break; } } }
/** * @brief Return the absolute heading of next * * @remark Uses @ref botNode global variable */ inline int8_t getNextHeading(void) { GraphNodeType nextNode; // info about nodes adjacent to botNode int8_t nextNodeIndex; // nextNode offset to nextBotNode int8_t nextHeading; // absolute direction to nextBotNode // get absolute direction of nextBotNode from node list getNode(botNode, &nextNode); nextNodeIndex = findValue(nextNode.adjNodes, nextNode.numAdjNodes, pathList[pathListIndex + 1]); // get next heading or report error if (nextNodeIndex == -1) { fatalError("pathList error", ""); } nextHeading = nextNode.adjHeadings[nextNodeIndex]; return nextHeading; }
const void* SipXHandleMap::removeHandle(SIPXHANDLE handle) { lock() ; releaseHandleRef(handle); const void* pRC = NULL ; UtlInt key(handle) ; UtlInt* pCount = static_cast<UtlInt*>(mLockCountHash.findValue(&key)) ; if (pCount == NULL || pCount->getValue() < 1) { UtlVoidPtr* pValue ; pValue = (UtlVoidPtr*) findValue(&key) ; if (pValue != NULL) { pRC = pValue->getValue() ; if(! destroy(&key)) { OsSysLog::add(FAC_SIPXTAPI, PRI_ERR, "SipXHandleMap::removeHandle failed to destroy handle: %d", handle); } } if (pCount) { if(! mLockCountHash.destroy(&key)) { OsSysLog::add(FAC_SIPXTAPI, PRI_ERR, "SipXHandleMap::removeHandle failed to destroy lock count for handle: %d", handle); } } } unlock() ; return pRC ; }