xref: /aosp_15_r20/external/lzma/CPP/7zip/Common/UniqBlocks.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // UniqBlocks.h
2 
3 #ifndef ZIP7_INC_UNIQ_BLOCKS_H
4 #define ZIP7_INC_UNIQ_BLOCKS_H
5 
6 #include "../../Common/MyBuffer.h"
7 #include "../../Common/MyString.h"
8 
9 struct C_UInt32_UString_Map
10 {
11   CRecordVector<UInt32> Numbers;
12   UStringVector Strings;
13 
Add_UInt32C_UInt32_UString_Map14   void Add_UInt32(const UInt32 n)
15   {
16     Numbers.AddToUniqueSorted(n);
17   }
FindC_UInt32_UString_Map18   int Find(const UInt32 n)
19   {
20     return Numbers.FindInSorted(n);
21   }
22 };
23 
24 
25 struct CUniqBlocks
26 {
27   CObjectVector<CByteBuffer> Bufs;
28   CUIntVector Sorted;
29   CUIntVector BufIndexToSortedIndex;
30 
31   unsigned AddUniq(const Byte *data, size_t size);
32   UInt64 GetTotalSizeInBytes() const;
33   void GetReverseMap();
34 
IsOnlyEmptyCUniqBlocks35   bool IsOnlyEmpty() const
36   {
37     return (Bufs.Size() == 0 || (Bufs.Size() == 1 && Bufs[0].Size() == 0));
38   }
39 };
40 
41 #endif
42