当前位置: 首页>>代码示例>>C++>>正文


C++ TIntPrV::Clr方法代码示例

本文整理汇总了C++中TIntPrV::Clr方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntPrV::Clr方法的具体用法?C++ TIntPrV::Clr怎么用?C++ TIntPrV::Clr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TIntPrV的用法示例。


在下文中一共展示了TIntPrV::Clr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetFqNmObjIdPrV

void TNmObjBs::GetFqNmObjIdPrV(
 const TStr& TargetNmObjStr, TIntPrV& FqNmObjIdPrV) const {
  //printf("Searching %s ...", TargetNmObjStr.CStr());
  // get target named-object-id
  int TargetNmObjId=GetNmObjId(TargetNmObjStr);
  // collect target named-object frequencies
  TIntIntH NmObjIdToFqH;
  // traverse target named-object documents
  int NmObjDocs=GetNmObjDocs(TargetNmObjId);
  for (int NmObjDocIdN=0; NmObjDocIdN<NmObjDocs; NmObjDocIdN++){
    // get document-id
    int DocId=GetNmObjDocId(TargetNmObjId, NmObjDocIdN);
    // traverse named-object in document
    int DocNmObjs=GetDocNmObjs(DocId);
    for (int DocNmObjN=0; DocNmObjN<DocNmObjs; DocNmObjN++){
      // get named-object & frequency
      int NmObjId; int TermFq;
      GetDocNmObjId(DocId, DocNmObjN, NmObjId, TermFq);
      // increment named-object document frequency
      NmObjIdToFqH.AddDat(NmObjId)++;
    }
  }
  // get & sort frequency table
  FqNmObjIdPrV.Clr(); NmObjIdToFqH.GetDatKeyPrV(FqNmObjIdPrV);
  FqNmObjIdPrV.Sort(false);
}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:26,代码来源:nmobj.cpp

示例2: GetSorted_LinkWgtDstEntIdPrV

void TSkyGridEnt::GetSorted_LinkWgtDstEntIdPrV(
 const uint64& MnTm, const double& TopWgtSumPrc, TIntPrV& LinkWgtDstEntIdPrV) const {
  double AllLinkWgtSum=0;
  TIntIntH DstEntIdLinkWgtH;
  int LinkEnts=GetLinkEnts();
  for (int LinkEntN=0; LinkEntN<LinkEnts; LinkEntN++){
    int DstEntId=GetLinkEntId(LinkEntN);
    int EntLinks=GetEntLinks(LinkEntN);
    int EntLinkWgtSum=0;
    for (int EntLinkN=0; EntLinkN<EntLinks; EntLinkN++){
      const TSkyGridEntLinkCtx& EntLinkCtx=GetEntLinkCtx(LinkEntN, EntLinkN);
      if (EntLinkCtx.Tm>=MnTm){
        EntLinkWgtSum+=EntLinkCtx.LinkWgt;}
    }
    DstEntIdLinkWgtH.AddDat(DstEntId, EntLinkWgtSum);
    AllLinkWgtSum+=EntLinkWgtSum;
  }
  LinkWgtDstEntIdPrV.Clr(); DstEntIdLinkWgtH.GetDatKeyPrV(LinkWgtDstEntIdPrV);
  LinkWgtDstEntIdPrV.Sort(false);
  // cut long-tail
  if ((TopWgtSumPrc>0.0)&&(LinkWgtDstEntIdPrV.Len()>0)){
    int TopLinkWgt=LinkWgtDstEntIdPrV[0].Val1;
    if (TopLinkWgt>(3*AllLinkWgtSum)/LinkWgtDstEntIdPrV.Len()){
      double CutWgtSum=AllLinkWgtSum*(1-TopWgtSumPrc);
      int LastValN=LinkWgtDstEntIdPrV.Len()-1;
      while ((LastValN>0)&&(CutWgtSum>0)){
        CutWgtSum-=LinkWgtDstEntIdPrV[LastValN].Val1;
        LastValN--;
      }
      LinkWgtDstEntIdPrV.Trunc(LastValN+1);
    }
  }
}
开发者ID:Accio,项目名称:snap,代码行数:33,代码来源:skygrid.cpp

示例3: Get1CnComSzCnt

// Algorithm: Find all bridges, remove them from the graph, find largest component K
// now add all bridges that do not touch K, find connected components
void Get1CnComSzCnt(const PUNGraph& Graph, TIntPrV& SzCntV) {
  //TCnCom::GetWccCnt(Graph, SzCntV);  IAssertR(SzCntV.Len() == 1, "Graph is not connected.");
  TIntPrV EdgeV;
  GetEdgeBridges(Graph, EdgeV);
  if (EdgeV.Empty()) { SzCntV.Clr(false); return; }
  PUNGraph TmpG = TUNGraph::New();
  *TmpG = *Graph;
  for (int e = 0; e < EdgeV.Len(); e++) {
    TmpG->DelEdge(EdgeV[e].Val1, EdgeV[e].Val2);  }
  TCnComV CnComV;  GetWccs(TmpG, CnComV);
  IAssert(CnComV.Len() >= 2);
  const TIntV& MxWcc = CnComV[0].NIdV;
  TIntSet MxCcSet(MxWcc.Len());
  for (int i = 0; i < MxWcc.Len(); i++) { 
    MxCcSet.AddKey(MxWcc[i]); }
  // create new graph: bridges not touching MxCc of G with no bridges
  for (int e = 0; e < EdgeV.Len(); e++) {
    if (! MxCcSet.IsKey(EdgeV[e].Val1) &&  ! MxCcSet.IsKey(EdgeV[e].Val2)) {
      TmpG->AddEdge(EdgeV[e].Val1, EdgeV[e].Val2); }
  }
  GetWccSzCnt(TmpG, SzCntV);
  for (int c = 0; c < SzCntV.Len(); c++) {
    if (SzCntV[c].Val1 == MxCcSet.Len()) { 
      SzCntV.Del(c);  break; }
  }
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:28,代码来源:cncom.cpp

示例4: GetSorted_DocsEntIdPrV

/////////////////////////////////////////////////
// SkyGrid-Base
void TSkyGridBs::GetSorted_DocsEntIdPrV(TIntPrV& DocsEntIdPrV){
  TIntIntH EntIdToDocsH;
  for (int EntId=0; EntId<GetEnts(); EntId++){
    int Docs=GetEnt(EntId).GetDocIds();
    EntIdToDocsH.AddDat(EntId, Docs);
  }
  DocsEntIdPrV.Clr(); EntIdToDocsH.GetDatKeyPrV(DocsEntIdPrV);
  DocsEntIdPrV.Sort(false);
}
开发者ID:Accio,项目名称:snap,代码行数:11,代码来源:skygrid.cpp

示例5: TriadGetTestTUNGraph

// Test GetTriadParticip
// Number of nodes with x number of triangles it participates in
TEST(triad, TestGetTriadParticip) {
  // Test TUNGraph
  PUNGraph GraphTUN = TriadGetTestTUNGraph();
  TIntPrV TriadCntV;
  TSnap::GetTriadParticip(GraphTUN, TriadCntV);
  VerifyGetTriadParticip(TriadCntV);

  // Test TNGraph which is same as undirected.
  PNGraph GraphTN = TriadGetTestTNGraph();
  TriadCntV.Clr();
  TSnap::GetTriadParticip(GraphTN, TriadCntV);
  VerifyGetTriadParticip(TriadCntV);
  
  // Test TNEGraph which is same as undirected.
  PNEGraph GraphTNE = TriadGetTestTNEGraph();
  TriadCntV.Clr();
  TSnap::GetTriadParticip(GraphTN, TriadCntV);
  VerifyGetTriadParticip(TriadCntV);
}
开发者ID:Antobiotics,项目名称:snap,代码行数:21,代码来源:test-triad.cpp

示例6: GetNGramStrV

void TNGramBs::GetNGramStrV(
 const TStr& HtmlStr, TStrV& NGramStrV, TIntPrV& NGramBEChXPrV) const {
  TIntV NGramIdV; NGramStrV.Clr(); NGramBEChXPrV.Clr();
  TNGramBs::GetNGramIdV(HtmlStr, NGramIdV, NGramBEChXPrV);
  NGramStrV.Gen(NGramIdV.Len(), 0);
  for (int NGramIdN=0; NGramIdN<NGramIdV.Len(); NGramIdN++){
    TStr NGramStr=GetNGramStr(NGramIdV[NGramIdN]);
    NGramStrV.Add(NGramStr);
  }
}
开发者ID:bergloman,项目名称:qminer,代码行数:10,代码来源:phrase.cpp

示例7: SetActorCntryLangByMajority

// set actor's language and country
void TImdbNet::SetActorCntryLangByMajority() {
    // set language
  TIntPrV NIdToVal;
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
    if (! NI().IsActor()) { continue; }
    IAssert(NI().GetLang() == 0); // no language set
    IAssert(NI.GetInDeg() == 0);  // actors point to movies
    int Nbhs=0;  TIntH LangCntH;
    for (int e = 0; e < NI.GetOutDeg(); e++) {
      LangCntH.AddDat(NI.GetOutNDat(e).GetLang()) += 1;  Nbhs++; }
    if (LangCntH.IsKey(0)) { Nbhs-=LangCntH.GetDat(0); LangCntH.GetDat(0)=0; }
    LangCntH.SortByDat(false);
    if (LangCntH.GetKey(0) == 0) { continue; }
    if (LangCntH[0]*2 >= Nbhs) { 
      NIdToVal.Add(TIntPr(NI.GetId(), LangCntH.GetKey(0))); }
  }
  for (int i = 0; i < NIdToVal.Len(); i++) {
    GetNDat(NIdToVal[i].Val1).Lang = NIdToVal[i].Val2; }
  printf("  language set: %d\n", NIdToVal.Len());
  
  int cnt=0;
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) { if (NI().IsActor() && NI().GetLang()==0) cnt++; }
  printf("  Actors NO language: %d\n\n", cnt);
  // set country
  NIdToVal.Clr(true);
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
    if (! NI().IsActor()) { continue; }
    IAssert(NI().GetCntry() == 0); // no country set
    IAssert(NI.GetInDeg() == 0);   // actors point to movies
    int Nbhs=0; TIntH CntryCntH;
    for (int e = 0; e < NI.GetOutDeg(); e++) {
      CntryCntH.AddDat(NI.GetOutNDat(e).GetCntry()) += 1;  Nbhs++; }
    if (CntryCntH.IsKey(0)) { Nbhs-=CntryCntH.GetDat(0); CntryCntH.GetDat(0)=0; }
    CntryCntH.SortByDat(false);
    if (CntryCntH.GetKey(0) == 0) { continue; }
    if (CntryCntH[0]*2 >= Nbhs) { 
      NIdToVal.Add(TIntPr(NI.GetId(), CntryCntH.GetKey(0))); }
  }
  for (int i = 0; i < NIdToVal.Len(); i++) {
    GetNDat(NIdToVal[i].Val1).Cntry = NIdToVal[i].Val2; }
  printf("  country set: %d\n", NIdToVal.Len());
  cnt=0;
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) { if (NI().IsActor() && NI().GetCntry()==0) cnt++; }
  printf("  Actors NO country: %d\n\n", cnt);
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:46,代码来源:imdbnet.cpp


注:本文中的TIntPrV::Clr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。