~ubuntu-branches/ubuntu/trusty/advancecomp/trusty

« back to all changes in this revision

Viewing changes to 7z/BinTree.h

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Ozarowski
  • Date: 2006-05-13 21:15:49 UTC
  • Revision ID: james.westby@ubuntu.com-20060513211549-2vu7peis643ojcm5
Tags: upstream-1.15
ImportĀ upstreamĀ versionĀ 1.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "Portable.h"
 
2
#include "WindowIn.h"
 
3
 
 
4
namespace BT_NAMESPACE {
 
5
 
 
6
typedef UINT32 CIndex;
 
7
const UINT32 kMaxValForNormalize = (UINT32(1) << 31) - 1;
 
8
 
 
9
struct CPair
 
10
{
 
11
  CIndex Left;
 
12
  CIndex Right;
 
13
};
 
14
 
 
15
class CInTree: public NStream::NWindow::CIn
 
16
{
 
17
  UINT32 m_HistorySize;
 
18
  UINT32 m_MatchMaxLen;
 
19
 
 
20
  CIndex *m_Hash;
 
21
  
 
22
  #ifdef HASH_ARRAY_2
 
23
  CIndex *m_Hash2;
 
24
  #ifdef HASH_ARRAY_3
 
25
  CIndex *m_Hash3;
 
26
  #endif
 
27
  #endif
 
28
  
 
29
  CPair *m_Son;
 
30
  CPair *m_Base;
 
31
 
 
32
  UINT32 m_CutValue;
 
33
 
 
34
  void NormalizeLinks(CIndex *anArray, UINT32 aNumItems, INT32 aSubValue);
 
35
  void Normalize();
 
36
  void FreeMemory();
 
37
 
 
38
protected:
 
39
  virtual void AfterMoveBlock();
 
40
public:
 
41
  CInTree();
 
42
  ~CInTree();
 
43
  HRESULT Create(UINT32 aSizeHistory, UINT32 aKeepAddBufferBefore, UINT32 aMatchMaxLen, 
 
44
      UINT32 aKeepAddBufferAfter, UINT32 _dwSizeReserv = (1<<17));
 
45
        HRESULT Init(ISequentialInStream *aStream);
 
46
  void SetCutValue(UINT32 aCutValue) { m_CutValue = aCutValue; }
 
47
  UINT32 GetLongestMatch(UINT32 *aDistances);
 
48
  void DummyLongestMatch();
 
49
  HRESULT MovePos()
 
50
  {
 
51
    RETURN_IF_NOT_S_OK(CIn::MovePos());
 
52
    if (m_Pos == kMaxValForNormalize)
 
53
      Normalize();
 
54
    return S_OK;
 
55
  }
 
56
  void ReduceOffsets(INT32 aSubValue)
 
57
  {
 
58
    CIn::ReduceOffsets(aSubValue);
 
59
    m_Son += aSubValue;
 
60
  }
 
61
};
 
62
 
 
63
}
 
64