SNAP Library , Developer Reference  2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TStrPool64 Class Reference

#include <dt.h>

Collaboration diagram for TStrPool64:

List of all members.

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
TStrPool64operator= (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 >

Detailed Description

Definition at line 822 of file dt.h.


Constructor & Destructor Documentation

TStrPool64::TStrPool64 ( ::TSize  _MxBfL = 0,
::TSize  _GrowBy = 16*1024*1024 
)

Definition at line 1715 of file dt.cpp.

References AddStr(), Bf, IAssert, and MxBfL.

                                                 :
        MxBfL(_MxBfL), BfL(0), GrowBy(_GrowBy), Bf(NULL) {

    if (MxBfL > 0) { Bf = (char*)malloc(MxBfL); IAssert(Bf != NULL); }
    AddStr("");
}

Here is the call graph for this function:

TStrPool64::TStrPool64 ( const TStrPool64 StrPool)

Definition at line 1722 of file dt.cpp.

References Bf, BfL, IAssert, and MxBfL.

                                               : 
  MxBfL(StrPool.MxBfL), BfL(StrPool.BfL), GrowBy(StrPool.GrowBy) {
    if (Bf != NULL) { free(Bf); } else { IAssert(MxBfL == 0); }
    Bf = (char*)malloc(StrPool.MxBfL); IAssert(Bf != NULL); 
    memcpy(Bf, StrPool.Bf, BfL);
}
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();
}

Here is the call graph for this function:

Definition at line 832 of file dt.h.

{ Clr(true); }

Member Function Documentation

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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TStrPool64::Clr ( bool  DoDel = false)

Definition at line 1757 of file dt.cpp.

References Bf, BfL, and MxBfL.

                               { 
    BfL = 0; 
    if (DoDel && (Bf!=NULL)) { 
        free(Bf); 
        Bf = NULL; MxBfL = 0; 
    } 
}
int TStrPool64::Cmp ( uint64  Offset,
const char *  Str 
) const [inline]

Definition at line 848 of file dt.h.

References Assert.

                                                { Assert(Offset < BfL);
    if (Offset != 0) return strcmp(Bf + Offset, Str); else return strcmp("", Str); }
bool TStrPool64::Empty ( ) const [inline]

Definition at line 844 of file dt.h.

{ return (BfL == 0); }
uint64 TStrPool64::GetMemUsed ( ) const [inline]

Definition at line 842 of file dt.h.

{ return 3*sizeof(::TSize) + uint64(MxBfL); }
TStr TStrPool64::GetStr ( const uint64 StrId) const

Definition at line 1773 of file dt.cpp.

References Bf.

                                                 {
    ::TSize Offset = (::TSize)StrId;
    return TStr(Bf + Offset);
}
uint64 TStrPool64::Len ( ) const [inline]

Definition at line 845 of file dt.h.

Referenced by AddStr().

{return BfL;}

Here is the caller graph for this function:

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)

Definition at line 1747 of file dt.cpp.

References Bf, BfL, GrowBy, IAssert, and MxBfL.

                                                           {
  if (this != &StrPool) {
    GrowBy = StrPool.GrowBy;  MxBfL = StrPool.MxBfL;  BfL = StrPool.BfL;
    if (Bf != NULL) { free(Bf); } else { IAssert(MxBfL == 0); }
    Bf = (char*)malloc(MxBfL); IAssert(Bf != NULL); 
    memcpy(Bf, StrPool.Bf, BfL);
  }
  return *this;
}
uint64 TStrPool64::Reserved ( ) const [inline]

Definition at line 846 of file dt.h.

{ return MxBfL; }
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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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();
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class TPt< TStrPool64 > [friend]

Definition at line 822 of file dt.h.


Member Data Documentation

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().

Definition at line 822 of file dt.h.

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().


The documentation for this class was generated from the following files: