| 
    SNAP Library 2.0, Developer Reference
    2013-05-13 16:33:57
    
   SNAP, a general purpose, high performance system for analysis and manipulation of large networks 
   | 
  
  
  
 
#include <linalg.h>
Static Public Member Functions | |
| static void | SparseMerge (const TKeyDatV &SrcV1, const TKeyDatV &SrcV2, TKeyDatV &DstV) | 
Private Types | |
| typedef TVec< TKeyDat< TKey,  TDat > >  | TKeyDatV | 
typedef TVec<TKeyDat<TKey, TDat> > TSparseOps< TKey, TDat >::TKeyDatV [private] | 
        
| static void TSparseOps< TKey, TDat >::SparseMerge | ( | const TKeyDatV & | SrcV1, | 
| const TKeyDatV & | SrcV2, | ||
| TKeyDatV & | DstV | ||
| ) |  [inline, static] | 
        
Definition at line 548 of file linalg.h.
References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Clr(), and TVec< TVal, TSizeTy >::Len().
Referenced by TLinAlg::AddVec().
                                                                                              {
                DstV.Clr();
                const int Src1Len = SrcV1.Len();
                const int Src2Len = SrcV2.Len();
                int Src1N = 0, Src2N = 0;
                while (Src1N < Src1Len && Src2N < Src2Len) {
                        if (SrcV1[Src1N].Key < SrcV2[Src2N].Key) { 
                                DstV.Add(SrcV1[Src1N]); Src1N++;
                        } else if (SrcV1[Src1N].Key > SrcV2[Src2N].Key) { 
                                DstV.Add(SrcV2[Src2N]); Src2N++;
                        } else { 
                                DstV.Add(TKeyDat<TKey, TDat>(SrcV1[Src1N].Key, SrcV1[Src1N].Dat + SrcV2[Src2N].Dat));
                                Src1N++;  Src2N++; 
                        }
                }
                while (Src1N < Src1Len) { DstV.Add(SrcV1[Src1N]); Src1N++; }
                while (Src2N < Src2Len) { DstV.Add(SrcV2[Src2N]); Src2N++; }
        }

