| SNAP Library , Developer Reference
    2013-01-07 14:03:36
    SNAP, a general purpose, high performance system for analysis and manipulation of large networks | 
#include <dt.h>

| Public Member Functions | |
| TStrPool64 (::TSize _MxBfL=0,::TSize _GrowBy=16 *1024 *1024) | |
| TStrPool64 (const TStrPool64 &StrPool) | |
| TStrPool64 (TSIn &SIn, bool LoadCompact=true) | |
| ~TStrPool64 () | |
| void | Save (TSOut &SOut) const | 
| TStrPool64 & | operator= (const TStrPool64 &StrPool) | 
| uint64 | GetMemUsed () const | 
| bool | Empty () const | 
| uint64 | Len () const | 
| uint64 | Reserved () const | 
| void | Clr (bool DoDel=false) | 
| int | Cmp (uint64 Offset, const char *Str) const | 
| uint64 | AddStr (const TStr &Str) | 
| TStr | GetStr (const uint64 &StrId) const | 
| Static Public Member Functions | |
| static PStrPool64 | New (::TSize MxBfL=0,::TSize GrowBy=16 *1024 *1024) | 
| static PStrPool64 | Load (TSIn &SIn, bool LoadCompact=true) | 
| Private Member Functions | |
| void | Resize (const ::TSize &_MxBfL) | 
| Private Attributes | |
| TCRef | CRef | 
| ::TSize | MxBfL | 
| ::TSize | BfL | 
| ::TSize | GrowBy | 
| char * | Bf | 
| Friends | |
| class | TPt< TStrPool64 > | 
| TStrPool64::TStrPool64 | ( | ::TSize | _MxBfL = 0, | 
| ::TSize | _GrowBy = 16*1024*1024 | ||
| ) | 
| TStrPool64::TStrPool64 | ( | const TStrPool64 & | StrPool | ) | 
| TStrPool64::TStrPool64 | ( | TSIn & | SIn, | 
| bool | LoadCompact = true | ||
| ) | 
Definition at line 1729 of file dt.cpp.
References Bf, BfL, TSIn::GetCh(), GrowBy, IAssert, TSIn::Load(), TSIn::LoadCs(), and MxBfL.
: MxBfL(0), BfL(0), GrowBy(0), Bf(0) { uint64 _GrowBy, _MxBfL, _BfL; SIn.Load(_GrowBy); SIn.Load(_MxBfL); SIn.Load(_BfL); GrowBy = (::TSize)_GrowBy; MxBfL = (::TSize)_MxBfL; BfL = (::TSize)_BfL; if (LoadCompact) { MxBfL = BfL; } if (MxBfL > 0) { Bf = (char*)malloc(MxBfL); IAssert(Bf != NULL); } for (::TSize BfN = 0; BfN < _BfL; BfN++) { Bf[BfN] = SIn.GetCh(); } SIn.LoadCs(); }

| TStrPool64::~TStrPool64 | ( | ) |  [inline] | 
| uint64 TStrPool64::AddStr | ( | const TStr & | Str | ) | 
Definition at line 1765 of file dt.cpp.
References Bf, BfL, TStr::CStr(), TStr::Len(), Len(), MxBfL, and Resize().
Referenced by TStrPool64().
                                         {
    const int Len = Str.Len() + 1;
    if (BfL + Len > MxBfL) { Resize(BfL + Len); }
    memcpy(Bf + BfL, Str.CStr(), Len);
    ::TSize Offset = BfL;  BfL += Len;
    return uint64(Offset);
}


| void TStrPool64::Clr | ( | bool | DoDel = false | ) | 
| int TStrPool64::Cmp | ( | uint64 | Offset, | 
| const char * | Str | ||
| ) | const  [inline] | 
| bool TStrPool64::Empty | ( | ) | const  [inline] | 
| uint64 TStrPool64::GetMemUsed | ( | ) | const  [inline] | 
| TStr TStrPool64::GetStr | ( | const uint64 & | StrId | ) | const | 
| uint64 TStrPool64::Len | ( | ) | const  [inline] | 
| static PStrPool64 TStrPool64::Load | ( | TSIn & | SIn, | 
| bool | LoadCompact = true | ||
| ) |  [inline, static] | 
Definition at line 837 of file dt.h.
                                                             { 
      return PStrPool64(new TStrPool64(SIn, LoadCompact)); }
| static PStrPool64 TStrPool64::New | ( | ::TSize | MxBfL = 0, | 
| ::TSize | GrowBy = 16*1024*1024 | ||
| ) |  [inline, static] | 
Definition at line 835 of file dt.h.
                                                                      { 
      return PStrPool64(new TStrPool64(MxBfL, GrowBy)); }
| TStrPool64 & TStrPool64::operator= | ( | const TStrPool64 & | StrPool | ) | 
| uint64 TStrPool64::Reserved | ( | ) | const  [inline] | 
| void TStrPool64::Resize | ( | const ::TSize & | _MxBfL | ) |  [private] | 
Definition at line 1699 of file dt.cpp.
References Bf, TStr::Fmt(), GrowBy, IAssert, IAssertR, and MxBfL.
Referenced by AddStr().
                                           {
    ::TSize newSize = MxBfL;
    while (newSize < _MxBfL) {
        if (newSize >= GrowBy && GrowBy > 0) newSize += GrowBy;
        else if (newSize > 0) newSize *= 2;
        else newSize = (GrowBy > ::TSize(1024)) ? ::TSize(1024) : GrowBy;
        IAssert(newSize >= MxBfL); // assert we are growing
    }
    if (newSize > MxBfL) {
        Bf = (char *) realloc(Bf, newSize);
        IAssertR(Bf, TStr::Fmt("old Bf size: %u, new size: %u", MxBfL, newSize).CStr());
        MxBfL = newSize;
    }
    IAssert(MxBfL >= _MxBfL);
}


| void TStrPool64::Save | ( | TSOut & | SOut | ) | const | 
Definition at line 1740 of file dt.cpp.
References Bf, BfL, GrowBy, MxBfL, TSOut::PutCh(), TSOut::Save(), and TSOut::SaveCs().
                                       {
    uint64 _GrowBy = GrowBy, _MxBfL = MxBfL, _BfL = BfL;
    SOut.Save(_GrowBy);  SOut.Save(_MxBfL);  SOut.Save(_BfL);
    for (::TSize BfN = 0; BfN < _BfL; BfN++) { SOut.PutCh(Bf[BfN]); }
    SOut.SaveCs();
}

| friend class TPt< TStrPool64 >  [friend] | 
| char* TStrPool64::Bf  [private] | 
Definition at line 825 of file dt.h.
Referenced by AddStr(), Clr(), GetStr(), operator=(), Resize(), Save(), and TStrPool64().
| ::TSize TStrPool64::BfL  [private] | 
Definition at line 824 of file dt.h.
Referenced by AddStr(), Clr(), operator=(), Save(), and TStrPool64().
| TCRef TStrPool64::CRef  [private] | 
| ::TSize TStrPool64::GrowBy  [private] | 
Definition at line 824 of file dt.h.
Referenced by operator=(), Resize(), Save(), and TStrPool64().
| ::TSize TStrPool64::MxBfL  [private] | 
Definition at line 824 of file dt.h.
Referenced by AddStr(), Clr(), operator=(), Resize(), Save(), and TStrPool64().