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


C++ TIntV::Gen方法代码示例

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


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

示例1: GetSelectDIdV

void TVizMapContext::GetSelectDIdV(TIntV& DIdV) {
    DIdV.Gen(SelPointV.Len(), 0);
    const int SelPoints = SelPointV.Len();
    for (int SelPointN = 0; SelPointN < SelPoints; SelPointN++) {
        DIdV.Add(VizMapFrame->GetPoint(SelPointV[SelPointN])->GetDocId());
    }
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:7,代码来源:vizmapgks.cpp

示例2: GetNmObjDIdV

void TNmObjBs::GetNmObjDIdV(
 const PBowDocBs& BowDocBs, TIntV& BowDIdV, 
 const TStr& NmObjStr1, const TStr& NmObjStr2) const {
  // get first named-object-id
  int NmObjId1=GetNmObjId(NmObjStr1);
  TIntV NmObjDocIdV1; GetNmObjDocIdV(NmObjId1, NmObjDocIdV1);
  NmObjDocIdV1.Sort();
  // get second named-object-id
  TIntV NmObjDocIdV2;
  if (!NmObjStr2.Empty()){
    int NmObjId2=GetNmObjId(NmObjStr2);
    GetNmObjDocIdV(NmObjId2, NmObjDocIdV2);
    NmObjDocIdV2.Sort();
  }
  // create joint doc-id-vector
  TIntV NmObjDocIdV;
  if (NmObjDocIdV2.Empty()){
    NmObjDocIdV=NmObjDocIdV1;
  } else {
    NmObjDocIdV1.Intrs(NmObjDocIdV2, NmObjDocIdV);
  }
  // traverse named-object-documents to collect bow-document-ids
  BowDIdV.Gen(NmObjDocIdV.Len(), 0);
  for (int NmObjDocIdN=0; NmObjDocIdN<NmObjDocIdV.Len(); NmObjDocIdN++){
    TStr DocNm=GetDocNm(NmObjDocIdV[NmObjDocIdN]);
    int DId=BowDocBs->GetDId(DocNm);
    if (DId!=-1){
      BowDIdV.Add(DId);
    } 
  }
}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:31,代码来源:nmobj.cpp

示例3: GetNIdV

void TBPGraph::GetNIdV(TIntV& NIdV) const {
  NIdV.Gen(GetNodes(), 0);
  for (int N=LeftH.FFirstKeyId(); LeftH.FNextKeyId(N); ) {
    NIdV.Add(LeftH.GetKey(N)); }
  for (int N=RightH.FFirstKeyId(); RightH.FNextKeyId(N); ) {
    NIdV.Add(RightH.GetKey(N)); }
}
开发者ID:arbenson,项目名称:snap,代码行数:7,代码来源:graph.cpp

示例4: GetBlockLenV

void TBlobBs::GetBlockLenV(const PFRnd& FBlobBs, TIntV& BlockLenV){
  EAssert(FBlobBs->GetStr(BlockLenVNm.Len())==BlockLenVNm);
  BlockLenV.Gen(FBlobBs->GetInt());
  for (int BlockLenN=0; BlockLenN<BlockLenV.Len(); BlockLenN++){
    BlockLenV[BlockLenN]=FBlobBs->GetInt();}
  EAssert(FBlobBs->GetInt()==-1);
}
开发者ID:adobekan,项目名称:qminer,代码行数:7,代码来源:blobbs.cpp

示例5: GetDocIdV

void TYInvIx::GetDocIdV(
 const PYWordDs& WordDs, const int& MnDocFq, TIntV& DocIdV){
  IAssert(MnDocFq>=0);
  if (MnDocFq==0){
    DocIdV=AllDocIdV;
  } else {
    TIntIntH DocIdFqH(100); int MxDocFq=0;
    int WordIdN=WordDs->FFirstWordId(); int WordId; double WordFq;
    while (WordDs->FNextWordId(WordIdN, WordId, WordFq)){
      if (WordIdToFirstDocIdNH.IsKey(WordId)){
        int DocIdN=FFirstDocId(WordId); int DocId;
        while (FNextWordId(DocIdN, DocId)){
          DocIdFqH.AddDat(DocId)+=int(WordFq);
          MxDocFq=TInt::GetMx(MxDocFq, DocIdFqH.GetDat(DocId));
        }
      }
    }
    int NewMnDocFq=(MnDocFq<=MxDocFq) ? MnDocFq : MxDocFq-3;
    DocIdV.Gen(DocIdFqH.Len(), 0);
    int DocIdP=DocIdFqH.FFirstKeyId();
    while (DocIdFqH.FNextKeyId(DocIdP)){
      int DocId=DocIdFqH.GetKey(DocIdP);
      int DocFq=DocIdFqH[DocIdP];
      if (DocFq>=NewMnDocFq){DocIdV.Add(DocId);}
    }
  }
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:27,代码来源:yahoodm.cpp

示例6: GetBestWordIdV

void TYFSelBs::GetBestWordIdV(
 const int& DocId, const double& EstExp, const double& SumEstPrb,
 const PYWordDs& IntrsWordDs, TIntV& BestWordIdV){
  TIntFltKdV& WordIdEstKdV=DocIdToWordIdEstVV[DocId];
  TFltIntKdV WordEstIdKdV(WordIdEstKdV.Len(), 0);
  double MnWordEst=TFlt::Mx;
  for (int WordIdN=0; WordIdN<WordIdEstKdV.Len(); WordIdN++){
    int WordId=WordIdEstKdV[WordIdN].Key;
    double WordEst=pow(WordIdEstKdV[WordIdN].Dat, EstExp);
    if (IntrsWordDs->IsWordId(WordId)){
      WordEstIdKdV.Add(TFltIntKd(WordEst, WordId));
      MnWordEst=TFlt::GetMn(WordEst, MnWordEst);
    }
  }
  double SumWordEst=0;
  {for (int WordIdN=0; WordIdN<WordEstIdKdV.Len(); WordIdN++){
    SumWordEst+=(WordEstIdKdV[WordIdN].Key-=MnWordEst);}}
  WordEstIdKdV.Sort(false);

  {BestWordIdV.Gen(WordEstIdKdV.Len(), 0);
  SumWordEst*=SumEstPrb; int WordIdN=0;
  while ((SumWordEst>=0)&&(WordIdN<WordEstIdKdV.Len())){
    double WordEst=WordEstIdKdV[WordIdN].Key;
    int WordId=WordEstIdKdV[WordIdN].Dat;
    SumWordEst-=WordEst;
    BestWordIdV.Add(WordId);
    WordIdN++;
  }}
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:29,代码来源:yahoodm.cpp

示例7: GenPLSeq

///Generate sequence from Power law
void TAGMUtil::GenPLSeq(TIntV& SzSeq, const int& SeqLen, const double& Alpha, TRnd& Rnd, const int& Min, const int& Max) {
    SzSeq.Gen(SeqLen, 0);
    while (SzSeq.Len() < SeqLen) {
        int Sz = (int) TMath::Round(Rnd.GetPowerDev(Alpha));
        if (Sz >= Min && Sz <= Max) {
            SzSeq.Add(Sz);
        }
    }
}
开发者ID:RoyZhengGao,项目名称:CommunityEvaluation,代码行数:10,代码来源:agm.cpp

示例8: TopologicalSort

void TGraphCascade::TopologicalSort(TIntV& SortedNIdV) {
    int Nodes = Graph.GetNodes();
        
    SortedNIdV.Gen(Nodes, 0); // result
    THash<TInt, TBool> Marks(Nodes); // nodeid -> mark map
    THash<TInt,TBool> TempMarks(Nodes); // nodeid -> temp mark map
    THash<TInt, TBool> Added(Nodes);
    TIntV NIdV;  Graph.GetNIdV(NIdV); // all node ids

    // set marks
    for (int NodeN = 0; NodeN < Nodes; NodeN++) {
        int NodeId = NIdV[NodeN];
        Marks.AddDat(NodeId, false);
        TempMarks.AddDat(NodeId, false);
        Added.AddDat(NodeId, false);
    }

    TSStack<TInt> Stack;
    for (int NodeN = 0; NodeN < Nodes; NodeN++) {
        int NodeId = NIdV[NodeN];
        // select an unmarked node
        if (!Marks.GetDat(NodeId)) {
            Stack.Push(NodeId);
            while (!Stack.Empty()) {
                // visit TopNode
                int TopNodeId = Stack.Top();
                Marks.GetDat(TopNodeId) = true;
                TempMarks.GetDat(TopNodeId) = true;
                // add children, set their temp marks to true
                TNGraph::TNodeI NI = Graph.GetNI(TopNodeId);
                int Children = NI.GetOutDeg();
                bool IsFinal = true;
                for (int ChildN = 0; ChildN < Children; ChildN++) {
                    int ChildId = NI.GetOutNId(ChildN);
                    EAssertR(!TempMarks.GetDat(ChildId), "TGraphCascade::TopologicalSort: the graph is not a DAG!");
                    if (!Marks.GetDat(ChildId)) {
                        // unvisited node
                        IsFinal = false;
                        Stack.Push(ChildId);
                    }
                }
                if (IsFinal) {
                    // push TopNode to tail
                    if (!Added.GetDat(TopNodeId)) {
                        SortedNIdV.Add(TopNodeId);
                        Added.GetDat(TopNodeId) = true;
                    }
                    TempMarks.GetDat(TopNodeId) = false;
                    Stack.Pop();
                }
            }
        }
    }
    SortedNIdV.Reverse();
}
开发者ID:Bradeskojest,项目名称:qminer,代码行数:55,代码来源:graphprocess.cpp

示例9: GetDocIdV

/////////////////////////////////////////////////
// SkyGrid-Entity
void TSkyGridEnt::GetDocIdV(const TSkyGridBs* SkyGridBs,
 const uint64& MnTm, const uint64& MxTm, TIntV& DocIdV) const {
  DocIdV.Gen(GetDocIds(), 0);
  for (int DocN=0; DocN<GetDocIds(); DocN++){
    int DocId=GetDocId(DocN);
    PSkyGridDoc Doc=SkyGridBs->GetDoc(DocId);
    uint64 DocTm=Doc->GetTm();
    if (((MnTm==0)||(MnTm<=DocTm))&&((MxTm==0)||(DocTm<MxTm))){
      DocIdV.Add(DocId);
    }
  }
}
开发者ID:Accio,项目名称:snap,代码行数:14,代码来源:skygrid.cpp

示例10: GetMergedNmObj

void TNmObjBs::GetMergedNmObj(TIntV& NewNmObjIdV){
  // matching constraints
  int MnPfxLen=3; int MxSfxLen=2;

  // create transformation vector
  int NmObjs=NmObjWordStrVToDocIdVH.Len();
  NewNmObjIdV.Gen(NmObjs); NewNmObjIdV.PutAll(-1);

  // merging single words
  // merging statistics
  {int SingleWords=0; int ReducedSingleWords=0;
  // collect single words according to prefix
  TStrIntVH PfxStrToNmObjIdVH;
  for (int NmObjId=0; NmObjId<NmObjs; NmObjId++){
    if (NewNmObjIdV[NmObjId]!=-1){continue;}
    const TStrV& WordStrV=NmObjWordStrVToDocIdVH.GetKey(NmObjId);
    if (WordStrV.Len()==1){
      TStr PfxStr=WordStrV[0].GetSubStr(0, 2);
      PfxStrToNmObjIdVH.AddDat(PfxStr).Add(NmObjId);
      SingleWords++;
    }
  }
  // traverse word-groups with the same prefix
  int Pfxs=PfxStrToNmObjIdVH.Len();
  for (int PfxId=0; PfxId<Pfxs; PfxId++){
    // get & traverse word-group
    TIntV& NmObjIdV=PfxStrToNmObjIdVH[PfxId];
    for (int NmObjIdN=0; NmObjIdN<NmObjIdV.Len(); NmObjIdN++){
      int NmObjId=NmObjIdV[NmObjIdN];
      if (NewNmObjIdV[NmObjId]!=-1){continue;}
      NewNmObjIdV[NmObjId]=NmObjId;
      const TStr& WordStr=NmObjWordStrVToDocIdVH.GetKey(NmObjId)[0];
      int Fq=NmObjWordStrVToDocIdVH[NmObjId].Len();
      TIntPrV FqNmObjIdPrV(NmObjIdV.Len(), 0);
      FqNmObjIdPrV.Add(TIntPr(Fq, NmObjId));
      // traverse rest of the word-group for matching words
      for (int SubNmObjIdN=NmObjIdN+1; SubNmObjIdN<NmObjIdV.Len(); SubNmObjIdN++){
        int SubNmObjId=NmObjIdV[SubNmObjIdN];
        if (NewNmObjIdV[SubNmObjId]!=-1){continue;}
        const TStr& SubWordStr=NmObjWordStrVToDocIdVH.GetKey(SubNmObjId)[0];
        // test matching
        if (IsMatchPfx(WordStr, SubWordStr, MnPfxLen, MxSfxLen)){
          NewNmObjIdV[SubNmObjId]=NmObjId;
          int SubFq=NmObjWordStrVToDocIdVH[SubNmObjId].Len();
          FqNmObjIdPrV.Add(TIntPr(SubFq, SubNmObjId));
          //printf("%s -> %s\n", WordStr.CStr(), SubWordStr.CStr());
        }
      }
      // increment number of equivalence word-groups
      ReducedSingleWords++;
      // collapse matching words into most frequent word
      if (FqNmObjIdPrV.Len()>1){
        FqNmObjIdPrV.Sort(false);
        int MainNmObjId=FqNmObjIdPrV[0].Val2;
        NewNmObjIdV[MainNmObjId]=MainNmObjId;
        TStr MainWordStr=NmObjWordStrVToDocIdVH.GetKey(MainNmObjId)[0];
        //printf("[%s:", MainWordStr.CStr());
        for (int FqNmObjIdPrN=1; FqNmObjIdPrN<FqNmObjIdPrV.Len(); FqNmObjIdPrN++){
          int SubNmObjId=FqNmObjIdPrV[FqNmObjIdPrN].Val2;
          NewNmObjIdV[SubNmObjId]=MainNmObjId;
          //TStr& SubWordStr=NmObjWordStrVToDocIdVH.GetKey(SubNmObjId)[0];
          //printf(" %s", SubWordStr.CStr());
        }
        //printf("]\n");
      }
    }
  }
  // print statistics
  //printf("SingleWords:%d ReducedSingleWords:%d\n",
  // SingleWords, ReducedSingleWords);
  }

  // merging double words
  // merging statistics
  {int DoubleWords=0; int ReducedDoubleWords=0;
  // collect double words according to prefix
  TStrIntVH PfxStrToNmObjIdVH;
  for (int NmObjId=0; NmObjId<NmObjs; NmObjId++){
    if (NewNmObjIdV[NmObjId]!=-1){continue;}
    const TStrV& WordStrV=NmObjWordStrVToDocIdVH.GetKey(NmObjId);
    if (WordStrV.Len()==2){
      TStr PfxStr=WordStrV[0].GetSubStr(0, 2)+WordStrV[1].GetSubStr(0, 2);
      PfxStrToNmObjIdVH.AddDat(PfxStr).Add(NmObjId);
      DoubleWords++;
    }
  }
  // traverse word-groups with the same prefix
  int Pfxs=PfxStrToNmObjIdVH.Len();
  for (int PfxId=0; PfxId<Pfxs; PfxId++){
    // get & traverse word-group
    TIntV& NmObjIdV=PfxStrToNmObjIdVH[PfxId];
    for (int NmObjIdN=0; NmObjIdN<NmObjIdV.Len(); NmObjIdN++){
      int NmObjId=NmObjIdV[NmObjIdN];
      if (NewNmObjIdV[NmObjId]!=-1){continue;}
      NewNmObjIdV[NmObjId]=NmObjId;
      const TStr& WordStr1=NmObjWordStrVToDocIdVH.GetKey(NmObjId)[0];
      const TStr& WordStr2=NmObjWordStrVToDocIdVH.GetKey(NmObjId)[1];
      int Fq=NmObjWordStrVToDocIdVH[NmObjId].Len();
      TIntPrV FqNmObjIdPrV(NmObjIdV.Len(), 0);
      FqNmObjIdPrV.Add(TIntPr(Fq, NmObjId));
//.........这里部分代码省略.........
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:101,代码来源:nmobj.cpp

示例11: FilterCandToNmObjIdV


//.........这里部分代码省略.........
//    if (WordStr=="British"){
//      printf("");}
    // ignore
    if (IsNmObjAttr(WordStr, noaIgnore)){
      CandWordStrN++; continue;
    } 
    // collect named-object words
    TStrV WordStrV;
    forever {
      WordStrV.Add(WordStr);
      CandWordStrN++; WordStr=CandWordStrV[CandWordStrN];
      if (IsTagStr(WordStr)){break;}
      if (WordStr.Len()<=1){break;}
      if (IsNmObjAttr(WordStr, noaIgnore)){CandWordStrN++; break;}
      if (IsNmObjAttr(WordStr, noaStandalone)){break;}
      if (IsNmObjAttr(WordStrV, noaStandalone)){break;}
    }
    // get normalized version of named-object
    TStrV NrWordStrV; GetNrNmObjStrV(WordStrV, NrWordStrV);
    // simple filters
    if (IsNmObjAttr(NrWordStrV, noaIgnore)){continue;}
    if (IsNmObjAttr(NrWordStrV, noaFirstName)){continue;}
    if (NrWordStrV.Len()>5){
      while (NrWordStrV.Len()>2){NrWordStrV.Del(0);}}
    if (NrWordStrV.Len()==1){
      TStr UcWordStr=ChDef->GetUcStr(NrWordStrV[0]);
      if (SwSet->IsIn(UcWordStr, true)){continue;}
    }
    // add named object
    NmObjIdWordStrVV.Add(NrWordStrV);
  }
  // merge similar words
  for (int NmObjN=0; NmObjN<NmObjIdWordStrVV.Len(); NmObjN++){
    TStrV& WordStrV=NmObjIdWordStrVV[NmObjN];
    if (WordStrV.Len()==1){
      // merge single words
      for (int SubNmObjN=0; SubNmObjN<NmObjIdWordStrVV.Len(); SubNmObjN++){
        TStrV& SubWordStrV=NmObjIdWordStrVV[SubNmObjN];
        if (SubWordStrV.Len()==1){
          if (WordStrV[0]!=SubWordStrV[0]){
            if (IsMatchPfx(WordStrV[0], SubWordStrV[0], 3, 4)){
              // normalize to shorter string
              if (WordStrV[0].Len()<SubWordStrV[0].Len()){SubWordStrV=WordStrV;}
              else {WordStrV=SubWordStrV;}
            }
          }
        }
      }
    } else
    if (WordStrV.Len()>=2){
      TStr LastNm=WordStrV.Last();
      for (int SubNmObjN=0; SubNmObjN<NmObjIdWordStrVV.Len(); SubNmObjN++){
        TStrV& SubWordStrV=NmObjIdWordStrVV[SubNmObjN];
        if (SubWordStrV.Len()==1){
          // merge last-name with [first-name,last-name] pairs
          TStr SubLastNm=SubWordStrV[0];
          if (LastNm!=SubLastNm){
            if (IsMatchPfx(LastNm, SubLastNm, 3, 4)){
              if (LastNm.Len()<SubLastNm.Len()){SubWordStrV=WordStrV;} 
              else {WordStrV=SubWordStrV;}
            }
          }
        } else
        if (false&&(SubWordStrV.Len()==2)){
          // merge [first-name,last-name] with [first-name,last-name] pairs
          if ((WordStrV[0]!=SubWordStrV[0])||(WordStrV[1]!=SubWordStrV[1])){
            if ((IsMatchPfx(WordStrV[0], SubWordStrV[0], 3, 4))&&
             (IsMatchPfx(WordStrV[1], SubWordStrV[1], 3, 4))){
              // normalize to shorter string (first word)
              if (WordStrV[0].Len()<SubWordStrV[0].Len()){
                SubWordStrV[0]=WordStrV[0];}
              else {WordStrV[0]=SubWordStrV[0];}
              // normalize to shorter string (second word)
              if (WordStrV[1].Len()<SubWordStrV[1].Len()){
                SubWordStrV[1]=WordStrV[1];}
              else {WordStrV[1]=SubWordStrV[1];}
            }
          }
        }
      }
    }
  }
  // get named-objects-ids
  NmObjIdV.Gen(NmObjIdWordStrVV.Len(), 0);
  {for (int NmObjN=0; NmObjN<NmObjIdWordStrVV.Len(); NmObjN++){
    TStrV& NmObjWordStrV=NmObjIdWordStrVV[NmObjN];
    int NmObjId=GetNmObjId(NmObjWordStrV, true);
    NmObjIdV.Add(NmObjId);
  }}
  // dump
  if (DumpP){
    printf("Named-Objects: ");
    for (int NmObjN=0; NmObjN<NmObjIdV.Len(); NmObjN++){
      int NmObjId=NmObjIdV[NmObjN];
      TStr NmObjStr=GetNmObjStr(NmObjId);
      printf("%s ", NmObjStr.CStr());
    }
    printf("\n");
  }
}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:101,代码来源:nmobj.cpp

示例12: GetNIdV

void TUNGraph::GetNIdV(TIntV& NIdV) const {
  NIdV.Gen(GetNodes(), 0);
  for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
    NIdV.Add(NodeH.GetKey(N)); }
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:5,代码来源:graph.cpp

示例13: GetEIdV

void TNEGraph::GetEIdV(TIntV& EIdV) const {
  EIdV.Gen(GetEdges(), 0);
  for (int E=EdgeH.FFirstKeyId(); EdgeH.FNextKeyId(E); ) {
    EIdV.Add(EdgeH.GetKey(E));
  }
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:6,代码来源:graph.cpp

示例14: GetNIdV

void TMultimodalGraphImplB::GetNIdV(TIntV& NIdV) const {
  NIdV.Gen(GetNodes(), 0);
  for (int N=NodeToModeMapping.FFirstKeyId(); NodeToModeMapping.FNextKeyId(N); ) {
    NIdV.Add(NodeToModeMapping.GetKey(N));
  }
}
开发者ID:deepakn94,项目名称:snap-dev,代码行数:6,代码来源:multimodalGraphImplB.cpp


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