3 template <
class TKey,
class TFDat,
class TVDat>
10 template <
class TKey,
class TFDat,
class TVDat>
26 const TKey& _Key,
const TFDat& _FDat,
const TBlobPt& _VDatBPt=
TBlobPt()):
51 template <
class TKey,
class TFDat,
class TVDat>
53 const TBlobPt& BlobPt,
void* RefToBs){
68 template <
class TKey,
class TFDat,
class TVDat>
98 int PortN=-1;
TBlobPt PrevKeyId;
99 GetKeyInfo(Key, PortN, PrevKeyId, KeyId, FHashKey);}
102 const bool& ChangeFDat,
const TFDat& FDat,
103 const bool& ChangeVDatBPt,
const TBlobPt& VDatBPt);
106 const bool& ChangeFDat,
const TFDat& FDat,
107 const bool& ChangeVDat,
const TVDat& VDat);
110 const int& Ports,
const int& MxMemUsed);
127 return AddDat(Key,
false, TFDat(),
true, VDat);}
129 return AddDat(Key,
true, FDat,
true, VDat);}
131 void DelKey(
const TKey& Key);
159 template <
class TKey,
class TFDat,
class TVDat>
164 PortN=abs(Key.GetPrimHashCd())%PortV.Len();
170 FHashKey=GetFHashKey(KeyId);
171 while ((!KeyId.
Empty())&&(FHashKey->Key!=Key)){
173 KeyId=FHashKey->Next;
174 if (!KeyId.
Empty()){FHashKey=GetFHashKey(KeyId);}
179 template <
class TKey,
class TFDat,
class TVDat>
182 const int& Ports,
const int& MxMemUsed):
183 Access(_Access), HashBBs(), PortV(), Keys(0),
184 FHashKeyCache(MxMemUsed, 100003, GetVoidThis()){
206 template <
class TKey,
class TFDat,
class TVDat>
210 FHashKeyCache.Flush();
212 TBlobPt HdBPt=HashBBs->GetFirstBlobPt();
213 TMOut HdSOut; Keys.
Save(HdSOut); PortV.Save(HdSOut);
214 HashBBs->PutBlob(HdBPt, HdSOut.
GetSIn());
218 template <
class TKey,
class TFDat,
class TVDat>
221 const bool& ChangeFDat,
const TFDat& FDat,
222 const bool& ChangeVDatBPt,
const TBlobPt& VDatBPt){
225 GetKeyInfo(Key, PortN, PrevKeyId, KeyId, FHashKey);
235 FHashKeyCache.Put(FHashKeyBPt, FHashKey);
236 FHashKey->PutModified(
false);
240 if (PrevKeyId.
Empty()){
243 PHashKey PrevFHashKey=GetFHashKey(PrevKeyId);
244 PrevFHashKey->Next=KeyId;
245 PrevFHashKey->PutModified(
true);
249 if (ChangeFDat){FHashKey->FDat=FDat;}
250 if (ChangeVDatBPt){FHashKey->VDatBPt=VDatBPt;}
251 if (ChangeFDat||ChangeVDatBPt){
252 FHashKey->PutModified(
true);}
257 template <
class TKey,
class TFDat,
class TVDat>
260 const bool& ChangeFDat,
const TFDat& FDat,
261 const bool& ChangeVDat,
const TVDat& VDat){
264 GetKeyInfo(Key, KeyId, FHashKey);
273 VDatBPt=HashBBs->PutBlob(VDatMOut.
GetSIn());
275 VDatBPt=HashBBs->PutBlob(FHashKey->VDatBPt, VDatMOut.
GetSIn());
280 KeyId=AddKey(Key, ChangeFDat, FDat, ChangeVDat, VDatBPt);
284 template <
class TKey,
class TFDat,
class TVDat>
288 GetKeyInfo(Key, PortN, PrevKeyId, KeyId, FHashKey);
292 if (PrevKeyId.
Empty()){
293 PortV[PortN]=FHashKey->Next;
295 PHashKey PrevFHashKey=GetFHashKey(PrevKeyId);
296 PrevFHashKey->Next=FHashKey->Next;
297 PrevFHashKey->PutModified(
true);
300 if (!FHashKey->VDatBPt.
Empty()){
301 HashBBs->DelBlob(FHashKey->VDatBPt);}
303 HashBBs->DelBlob(KeyId);
304 FHashKeyCache.Del(KeyId,
false);
307 template <
class TKey,
class TFDat,
class TVDat>
309 const TKey& Key, TFDat& FDat){
312 GetKeyInfo(Key, KeyId, FHashKey);
318 template <
class TKey,
class TFDat,
class TVDat>
322 GetKeyInfo(Key, KeyId, FHashKey);
324 PSIn SIn=HashBBs->GetBlob(FHashKey->VDatBPt);
330 template <
class TKey,
class TFDat,
class TVDat>
332 const TKey& Key, TFDat& FDat, TVDat& VDat){
335 GetKeyInfo(Key, KeyId, FHashKey);
339 PSIn SIn=HashBBs->GetBlob(FHashKey->VDatBPt);
345 template <
class TKey,
class TFDat,
class TVDat>
347 const TBlobPt& KeyId, TKey& Key, TFDat& FDat){
349 PHashKey FHashKey=GetFHashKey(KeyId);
356 template <
class TKey,
class TFDat,
class TVDat>
358 const TBlobPt& KeyId, TKey& Key, TFDat& FDat, TVDat& VDat){
360 PHashKey FHashKey=GetFHashKey(KeyId);
366 PSIn SIn=HashBBs->GetBlob(FHashKey->VDatBPt);
371 template <
class TKey,
class TFDat,
class TVDat>
373 return HashBBs->FFirstBlobPt();
376 template <
class TKey,
class TFDat,
class TVDat>
380 while (HashBBs->FNextBlobPt(TrvBlobPt, KeyId, SIn)){
382 if (Type==
fhbtKey){
return true;}
PHashKey GetFHashKey(const TBlobPt &KeyId)
TFHashKey & operator=(const TFHashKey &FHashKey)
virtual TBlobPt GetFirstBlobPt()=0
TBlobPt AddVDat(const TKey &Key, const TVDat &VDat)
void GetKeyInfo(const TKey &Key, TBlobPt &KeyId, PHashKey &FHashKey)
void GetKeyFDat(const TBlobPt &KeyId, TKey &Key, TFDat &FDat)
void Save(TSOut &SOut) const
PSIn GetSIn(const bool &IsCut=true, const int &CutBfL=-1)
TPt< TFHash< TKey, TFDat, TVDat > > PFHash
TBlobPt GetKeyId(const TKey &Key)
bool IsKey(const TKey &Key)
TSizeTy GetMemUsed() const
Returns the memory footprint (the number of bytes) of the vector.
TPt< TFHashKey< TKey, TFDat, TVDat > > PFHashKey
void GetKey(const TBlobPt &KeyId, TKey &Key)
void Save(TSOut &SOut) const
bool IsKey(const TKey &Key, TBlobPt &KeyId)
static PFHashKey Load(TSIn &SIn)
TBlobPt GetFVDat(const TKey &Key, TFDat &FDat, TVDat &VDat)
TFHashKey< TKey, TFDat, TVDat > THashKey
void GetKeyFVDat(const TBlobPt &KeyId, TKey &Key, TFDat &FDat, TVDat &VDat)
TBlobPt AddFDat(const TKey &Key, const TFDat &FDat)
TBlobPt GetVDat(const TKey &Key, TVDat &VDat)
void DelKey(const TKey &Key)
TBlobPt AddKey(const TKey &Key, const bool &ChangeFDat, const TFDat &FDat, const bool &ChangeVDatBPt, const TBlobPt &VDatBPt)
void Save(const bool &Bool)
TFHash & operator=(const TFHash &)
bool FNextKeyId(TBlobPt &TrvBlobPt, TBlobPt &KeyId)
void GetKeyInfo(const TKey &Key, int &PortN, TBlobPt &PrevKeyId, TBlobPt &KeyId, PHashKey &FHashKey)
void OnDelFromCache(const TBlobPt &BlobPt, void *RefToBs)
void Save(TSOut &SOut) const
TFHash< TKey, TFDat, TVDat > THash
TBlobPt AddFVDat(const TKey &Key, const TFDat &FDat, const TVDat &VDat)
TCache< TBlobPt, PHashKey > FHashKeyCache
virtual TBlobPt PutBlob(const PSIn &SIn)=0
void DelKeyId(const TBlobPt &KeyId)
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
static PFHash Load(TSIn &)
TFHashKey(const TBlobPt &_Next, const TKey &_Key, const TFDat &_FDat, const TBlobPt &_VDatBPt=TBlobPt())
TBlobPt GetFDat(const TKey &Key, TFDat &FDat)
void * GetVoidThis() const
void Save(TSOut &SOut) const
TFHash(const TStr &HashFNm, const TFAccess &_Access, const int &Ports, const int &MxMemUsed)
void PutModified(const bool &_Modified)
TBlobPt AddDat(const TKey &Key, const bool &ChangeFDat, const TFDat &FDat, const bool &ChangeVDat, const TVDat &VDat)
virtual PSIn GetBlob(const TBlobPt &BlobPt)=0