static void drawit(void) { /* Draw calculator */ int i,j; char line[40],tline[40],bline[40]; cset(1); line[0]=DTLHC; for (i=1;i<38;i++) line[i]=DHORZ; line[38]=DTRHC; line[39]='\0'; aprint(ORDINARY,1,1,line); for (i=1;i<22;i++) apchar(ORDINARY,1,1+i,DVERT); line[0]=DBLHC; line[38]=DBRHC; aprint(ORDINARY,1,23,line); for (i=1;i<22;i++) apchar(ORDINARY,39,1+i,DVERT); line[0]=LSIDE; /* draw in the bar */ for (i=1;i<38;i++) line[i]=HORZ; line[38]=RSIDE; aprint(ORDINARY,1,4,line); line[0]=tline[0]=bline[0]=SPACE; line[36]=tline[36]=bline[36]=SPACE; line[37]=tline[37]=bline[37]='\0'; for (i=1;i<36;i++) { switch (i%5) { case 1 : tline[i]=TLHC; bline[i]=BLHC; line[i]=VERT; break; default: tline[i]=HORZ; bline[i]=HORZ; line[i]=SPACE; break; case 0 : tline[i]=TRHC; bline[i]=BRHC; line[i]=VERT; break; } } for (j=0;j<6;j++) { aprint(ORDINARY,2,5+3*j,tline); aprint(ORDINARY,2,6+3*j,line); aprint(ORDINARY,2,7+3*j,bline); } cset(0); for (j=0;j<6;j++) for (i=0;i<7;i++) aprint(ORDINARY,4+5*i,6+3*j,keys[j][i]); aprint(HELPCOL,2,24,"Type 'H' for help on/off, 'O' to exit"); cotstr(x,mip->IOBUFF); just((char *)mip->IOBUFF); getstat(); show(TRUE); }
void HBase::addFloatData(const char * dataName, unsigned count) { FloatsHDataset cset(dataName); cset.setNumFloats(count); cset.create(fObjectId); cset.close(); }
void TBAssociate::printTest() { int array[] = {1, 2, 6, 3, 5 ,5}; set<int> cset(array, array + 5); std::sort(array, array+5, setCompare()); printIterator(cset.begin(),cset.end()); cset.insert(5); cset.insert(10); // printIterator(cset.begin(),cset.end()); if(cset.find(5) != cset.end()) { cout << "找到了5" << endl; } cout << "5的个数--->" << cset.count(5) << endl; // cset.erase(5); printIterator(cset.begin(),cset.end()); set<int>::iterator iterLower, itUp; iterLower = cset.lower_bound(2); itUp = cset.upper_bound(5); // cset.erase(iterLower, itUp); printIterator(cset.begin(), cset.end()); std::pair<set<int>::iterator, set<int>::iterator> ret; ret = cset.equal_range(5); cout << "ret.first::" << *ret.first << endl; cout << "ret.second::"<< *ret.second<< endl; printIterator(cset.begin(), cset.end()); // cset.insert(5); }
void HBase::addCharData(const char * dataName, unsigned count) { HCharData cset(dataName); cset.setNumChars(count); cset.create(fObjectId); cset.close(); }
int alsa_set_hp_volume(int value, int percent) { int ret; char *argv[3]; if (value < 0 || value > 100) return -1; if (percent) volume_percent = value; argv[0] = malloc(256); argv[1] = malloc(256); argv[2] = malloc(256); strcpy(argv[0], "numid=3,iface=MIXER,name=\'HP Playback Volume\'"); sprintf(argv[1], "%i", value); ret = cset(2, argv, 0, 0) ; free(argv[0]); free(argv[1]); free(argv[2]); volume_percent = -1; if (ret < 0) return ret; else return 0; }
void HBase::addIntData(const char * dataName, unsigned count) { IndicesHDataset cset(dataName); cset.setNumIndices(count); cset.create(fObjectId); cset.close(); }
void HBase::writeMatrix44Data(const char * dataName, unsigned count, Matrix44F *value, HDataset::SelectPart * part) { FloatsHDataset cset(dataName); cset.setNumFloats(count * 16); cset.open(fObjectId); if(!cset.write((char *)value, part)) std::cout<<"error: h5 base "<<fObjectId<<" cannot write mat44 data "<<dataName<<"!\n"; cset.close(); }
void HBase::writeMatrix33Data(const char * dataName, unsigned count, Matrix33F *value, HDataset::SelectPart * part) { FloatsHDataset cset(dataName); cset.setNumFloats(count * 9); cset.open(fObjectId); if(!cset.write((char *)value, part)) std::cout<<dataName<<" write failed"; cset.close(); }
void HBase::writeIntData(const char * dataName, unsigned count, int *value, HDataset::SelectPart * part) { IndicesHDataset cset(dataName); cset.setNumIndices(count); cset.open(fObjectId); if(!cset.write((char *)value, part)) std::cout<<dataName<<" write failed"; cset.close(); }
char HBase::readMatrix33Data(const char * dataName, unsigned count, Matrix33F *dst, HDataset::SelectPart * part) { FloatsHDataset cset(dataName); cset.setNumFloats(count * 9); if(!cset.open(fObjectId)) { std::cout<<dataName<<" open failed"; return 0; } cset.read((char *)dst, part); cset.close(); return 1; }
char HBase::readIntData(const char * dataName, unsigned count, unsigned *dst, HDataset::SelectPart * part) { IndicesHDataset cset(dataName); cset.setNumIndices(count); if(!cset.open(fObjectId)) { std::cout<<dataName<<" open failed"; return 0; } cset.read((char *)dst, part); cset.close(); return 1; }
void Multipart_CacheStorage::CreateNextElementL(URL new_target, const OpStringC8 &content_type_str, OpStringS8 &content_encoding, BOOL no_store) { loading_item = NULL; if(new_target.IsEmpty()) { ParameterList type(KeywordIndex_HTTP_General_Parameters); ANCHOR(ParameterList, type); URLContentType new_content_type = URL_UNDETERMINED_CONTENT; unsigned short new_charset_id = 0; type.SetValueL(content_type_str.CStr(),PARAM_SEP_SEMICOLON|PARAM_STRIP_ARG_QUOTES); Parameters *element = type.First(); Parameters *content_type_elm = NULL; if(element) { do{ element->SetNameID(HTTP_General_Tag_Unknown); ANCHORD(OpStringS8, stripped_name); BOOL illegal_name=FALSE; if(element->Name()) { stripped_name.SetL(element->Name()); int i; for(i=0;((unsigned char) stripped_name[i])>=32 && ((unsigned char) stripped_name[i])<=127;i++) ; if (stripped_name[i]!=0) illegal_name=TRUE; } if(illegal_name) { new_content_type = URL_UNKNOWN_CONTENT; break; } OpStringC8 ctype(element->Name()); content_type_elm = element; if (Viewer *v = g_viewers->FindViewerByMimeType(ctype)) new_content_type = v->GetContentType(); else new_content_type = URL_UNKNOWN_CONTENT; if(!ctype.IsEmpty() && (strni_eq(ctype.CStr(), "TEXT/", 5) || strni_eq(ctype.CStr(), "APPLICATION/XML", 15) || strni_eq(ctype.CStr(), "APPLICATION/XHTML", 17))) element = type.GetParameterByID(HTTP_General_Tag_Charset, PARAMETER_ASSIGNED_ONLY); else element = NULL; if(element) { OpStringC8 cset(element->Value()); new_charset_id = (cset.HasContent() ? g_charsetManager->GetCharsetIDL(cset.CStr()) : 0); } }while(0); } // Use cache elements OpStackAutoPtr<Cache_Storage> new_item(NULL); #ifndef RAMCACHE_ONLY if(no_store) #endif new_item.reset(OP_NEW_L(Memory_Only_Storage, (url))); #ifndef RAMCACHE_ONLY else new_item.reset(OP_NEW_L(Persistent_Storage, (url))); #endif new_item->TakeOverContentEncoding(content_encoding); if(content_type_elm) new_item->SetMIME_TypeL(content_type_elm->Name()); new_item->SetContentType(new_content_type); new_item->SetCharsetID(new_charset_id); loading_item = OP_NEW_L(MultipartStorage_Item, (new_item.get())); #ifdef DEBUG_MULPART PrintfTofile("mulpart.txt", "\nCreated new bodypart for %s\n", url->GetAttribute(URL::KName_Username_Password_Escaped_NOT_FOR_UI).CStr()); PrintfTofile("mulpart1.txt", "\nCreated new bodypart for %s\n", url->GetAttribute(URL::KName_Username_Password_Escaped_NOT_FOR_UI).CStr()); //PrintfTofile("msg.txt", "New bodypart %08x\n", url->GetID()); #endif loading_item->Into(&unused_cache_items); new_item.release(); if((used_cache_items.Empty() || bodypart_status == Multipart_BoundaryRead) && loading_item->Pred() == NULL) { SetMultipartStatus(Multipart_HeaderLoaded); loading_item->header_loaded_sent = TRUE; } first_bodypart_created = TRUE; } #if defined(MIME_ALLOW_MULTIPART_CACHE_FILL) || defined(WBMULTIPART_MIXED_SUPPORT) else { current_target = new_target; URL_DataStorage *ct_ds = current_target->GetRep()->GetDataStorage(); if (ct_ds) { ct_ds->ResetCache(); ct_ds->BroadcastMessage(MSG_HEADER_LOADED, current_target->Id(), current_target->GetAttribute(URL::KIsFollowed) ? 0 : 1, MH_LIST_NOT_INLINE_ONLY | MH_LIST_NOT_LOAD_SILENT_ONLY); } current_target->SetAttributeL(URL::KHTTP_Response_Code, HTTP_OK); current_target->SetAttributeL(URL::KCachePolicy_NoStore, no_store); current_target->SetAttributeL(URL::KHTTPEncoding, content_encoding); current_target->SetAttributeL(URL::KMIME_ForceContentType, content_type_str); current_target->SetAttributeL(URL::KLoadStatus, URL_LOADING); InheritExpirationDataL(current_target, url); } #endif }
void SelectableGeometryFeatures::addAllLinesFromObservationList(const ObservationList &list) { const double LINETOLERANCE = 1e-7; int N = (int)list.size(); std::vector<int> used(N * N); std::vector<std::vector<int>> lines; for (int i = 0; i < N; ++i) { for (int j = i + 1; j < N; ++j) { if (used[i * N + j] || used[j * N + i]) continue; used[i * N + j] = used[j * N + i] = 1; corecvs::Vector3dd A, B, C, d, D; A = list[i].point; B = list[j].point; d = (B - A).normalised(); std::vector<int> line = {i, j}; for (int k = 0; k < N; ++k) { if (k == i || k == j) continue; C = list[k].point; D = C - A; double diff = !(D - (D & d) * d); if (diff < LINETOLERANCE) { used[i * N + k] = used[k * N + i] = used[j * N + k] = used[k * N + j] = 1; line.push_back(k); } } if (line.size() >= 3) { std::sort(line.begin(), line.end()); lines.push_back(line); } } } int idx = 0; for (auto& line: lines) { bool unique = true; std::set<int> cset(line.begin(), line.end()); for (int i = 0; i < idx; ++i) { int common = 0; for (auto& id: lines[i]) if (cset.count(id)) common++; if (common >= 2) { unique = false; break; } } if (unique) lines[idx++] = line; } lines.resize(idx); for (auto& line: lines) { auto* path = appendNewPath(); for (auto id: line) addVertexToPath(appendNewVertex(list[id].projection), path); } }
/* void GenVar (); */ NS_IMETHODIMP nsChlVarGenerator_1::GenVar() { //Get the target class PRInt32 len=0; m_model->GetClassCount(&len); double minValue=INT_MAX; Distance ld; std::list<int> classids; for(int i=0;i<len;i++) { nsCOMPtr<nsIAttVec> vec(nsnull); m_model->GetClassAtt(i, getter_AddRefs(vec) ); nsCOMPtr<nsIDOMNode> node(nsnull); vec->GetNode(getter_AddRefs(node)); nsCOMPtr<nsIDOMDocument> doc; vec->GetDoc(getter_AddRefs(doc)); nsCOMPtr<nsIDOMHTMLDocument> html=do_QueryInterface(doc); nsString docurl; html->GetURL(docurl); nsCString url; dUtil->GetLinkStr(node,0,url); std::string urlStr(url.get()); std::string docurlStr(NS_ConvertUTF16toUTF8(docurl).get()); LOG<<"url:"<<urlStr<<"\n"; LOG<<"docurl:"<<docurlStr<<"\n"; double tmp=ld.LD(urlStr,docurlStr); LOG<<"START Value:"<<tmp<<"\n"; double attValue; vec->GetValueByDim(0,&attValue); tmp+=attValue; LOG<<i<<"Second value:"<<tmp<<" Plus:"<<attValue<<"\n"; if(attValue==0) continue; vec->GetValueByDim(1,&attValue); tmp-=log(attValue)/log(2); LOG<<i<<"Third value:"<<tmp<<" SUB:"<<attValue<<"\n"; LOG<<i<<" minValue:"<<minValue<<"\n"; if(minValue>tmp) { classids.clear(); minValue=tmp; classids.push_back(i); }else if(fabs(minValue-tmp)<0.1) { classids.push_back(i); } } LOG<<"classid size:"<<classids.size()<<":"<<minValue<<"\n"; if(!classids.empty()) { int MaxCount=INT_MIN; int classid; for(std::list<int>::iterator it=classids.begin();it!=classids.end();++it) { nsCOMPtr<nsIAttSet> cset(nsnull); m_model->GetClassSet(*it, getter_AddRefs(cset)); PRInt32 tmplen=0; cset->GetLength(&tmplen); if(tmplen>MaxCount) { MaxCount=tmplen; classid=*it; } } LOG<<"classid"<<classid<<"\n"; nsCOMPtr<nsIAttSet> cset(nsnull); m_model->GetClassSet(classid, getter_AddRefs(cset)); PRInt32 vlen=0; cset->GetLength(&vlen); int chose=-1; double minatt=INT_MAX; string attnames=m_parm["PATH_ATTS"]; LOG<<"--------------------names:"<<attnames<<"\n"; std::vector<std::string> nameVec; if(attnames.length()>0) split(attnames, ";",nameVec); std::set<std::string> xpaths; for(int i=0;i<vlen;i++) { nsCOMPtr<nsIAttVec> vec(nsnull); cset->GetVectorByIndex(i, getter_AddRefs(vec)); nsresult rv; nsCOMPtr<nsIXpathUtil> xpathUtil=do_CreateInstance("@nyapc.com/XPCOM/nsXpathUtil;1",&rv); if (NS_FAILED(rv)) { continue; } for( std::vector<std::string>::iterator it=nameVec.begin();it!=nameVec.end();++it) { LOG<<"-----------------"<<*it<<"\n"; xpathUtil->AddAttName(nsCString(it->c_str())); } nsCOMPtr<nsIDOMDocument> doc; nsCOMPtr<nsIDOMNode> node; vec->GetDoc(getter_AddRefs(doc)); vec->GetNode(getter_AddRefs(node)); xpathUtil->SetDocument(doc); nsCString xpath; xpathUtil->GetXpath(node, 1,xpath); xpaths.insert(std::string(xpath.get())); } std::string name("box"); std::string value; for(std::set<std::string>::iterator it=xpaths.begin();it!=xpaths.end();++it) { value+=*it; std::set<std::string>::iterator tit=it; ++tit; if(tit!=xpaths.end()) value+="|"; } m_vars.insert(make_pair(name,value)); } return NS_OK; }