jp.gr.java_conf.dangan.util.lha

Class HashAndBinaryTreeSearch

Implemented Interfaces:
LzssSearchMethod

public class HashAndBinaryTreeSearch
extends Object
implements LzssSearchMethod

ハッシュと二分木を使った LzssSearchMethod の実装。
 データ圧縮ハンドブック[改定第二版]
        M.ネルソン/J.-L.ゲィリー 著
                萩原剛志・山口英 訳
                  ISBN4-8101-8605-9
                             5728円(税抜き,当方の購入当時の価格)
 
を参考にした。
二分木では、最長一致を見つけることはできるが、 最も近い一致を見つけられるとは限らないため、 LZSSで 一致位置が近い場所に偏る事を 利用するような -lh5- のような圧縮法では、 圧縮率はいくらか低下する。
 -- revision history --
 $Log: HashAndBinaryTreeSearch.java,v $
 Revision 1.0  2002/08/05 00:00:00  dangan
 add to version control
 [change]
     LzssSearchMethod のインタフェイス変更にあわせてインタフェイス変更
 [maintenance]
     ソース整備
     タブ廃止
     ライセンス文の修正

 
Version:
$Revision: 1.0 $
Author:
$Author: dangan $

Constructor Summary

HashAndBinaryTreeSearch(int DictionarySize, int MaxMatch, int Threshold, byte[] TextBuffer)
ハッシュと二分木を使用した検索機構を構築する。
ハッシュ関数はデフォルトのものを使用する。
HashAndBinaryTreeSearch(int DictionarySize, int MaxMatch, int Threshold, byte[] TextBuffer, String HashMethodClassName)
ハッシュと二分木を使用した LzssSearchMethod を構築する。

Method Summary

void
put(int position)
position から始まるデータパタンを ハッシュと二分木を使用した検索機構に登録する。
int
putRequires()
put() または searchAndPut() を使用して データパタンを二分木に登録する際に 必要とするデータ量を得る。
二分木は登録の際にデータパタンを構成する 全て(MaxMatchバイト)のデータを必要とする。
int
search(int position, int lastPutPos)
ハッシュと二分木を使用した検索機構に登録されたデータパタンを検索し position から始まるデータパタンと最長の一致を持つものを得る。
TextBuffer.length &lt position + MaxMatch となるような position では、 二分木を完全に走査しないため最長一致を得られるとは限らない。
int
searchAndPut(int position)
ハッシュと二分木を使用した検索機構に登録された データパタンから position から始まるデータパタンと 最長の一致を持つものを検索し、 同時に position から始まるデータパタンを ハッシュと二分木を使用した検索機構に登録する。
void
slide()
TextBuffer内の position までのデータを前方へ移動する際、 それに応じて ハッシュと二分木を使用した検索機構を構成するデータも TextBuffer内のデータと矛盾しないように前方へ移動する処理を行う。

Constructor Details

HashAndBinaryTreeSearch

public HashAndBinaryTreeSearch(int DictionarySize,
                               int MaxMatch,
                               int Threshold,
                               byte[] TextBuffer)
ハッシュと二分木を使用した検索機構を構築する。
ハッシュ関数はデフォルトのものを使用する。
Parameters:
DictionarySize - 辞書サイズ
MaxMatch - 最長一致長
Threshold - 圧縮、非圧縮の閾値
TextBuffer - LZSS圧縮を施すためのバッファ

HashAndBinaryTreeSearch

public HashAndBinaryTreeSearch(int DictionarySize,
                               int MaxMatch,
                               int Threshold,
                               byte[] TextBuffer,
                               String HashMethodClassName)
ハッシュと二分木を使用した LzssSearchMethod を構築する。
Parameters:
DictionarySize - 辞書サイズ
MaxMatch - 最長一致長
Threshold - 圧縮、非圧縮の閾値
TextBuffer - LZSS圧縮を施すためのバッファ
HashMethodClassName - Hash関数を提供するクラス名

Method Details

put

public void put(int position)
position から始まるデータパタンを ハッシュと二分木を使用した検索機構に登録する。
Specified by:
put in interface LzssSearchMethod
Parameters:
position - TextBuffer内のデータパタンの開始位置

putRequires

public int putRequires()
put() または searchAndPut() を使用して データパタンを二分木に登録する際に 必要とするデータ量を得る。
二分木は登録の際にデータパタンを構成する 全て(MaxMatchバイト)のデータを必要とする。
Specified by:
putRequires in interface LzssSearchMethod
Returns:
コンストラクタで与えた MaxMatch

search

public int search(int position,
                  int lastPutPos)
ハッシュと二分木を使用した検索機構に登録されたデータパタンを検索し position から始まるデータパタンと最長の一致を持つものを得る。
TextBuffer.length &lt position + MaxMatch となるような position では、 二分木を完全に走査しないため最長一致を得られるとは限らない。
Specified by:
search in interface LzssSearchMethod
Parameters:
position - TextBuffer内のデータパタンの開始位置。
lastPutPos - 最後に登録したデータパタンの開始位置。
Returns:
一致が見つかった場合は LzssOutputStream.createSearchReturn によって生成された一致位置と一致長の情報を持つ値、 一致が見つからなかった場合は LzssOutputStream.NOMATCH。

searchAndPut

public int searchAndPut(int position)
ハッシュと二分木を使用した検索機構に登録された データパタンから position から始まるデータパタンと 最長の一致を持つものを検索し、 同時に position から始まるデータパタンを ハッシュと二分木を使用した検索機構に登録する。
Specified by:
searchAndPut in interface LzssSearchMethod
Parameters:
position - TextBuffer内のデータパタンの開始位置。
Returns:
一致が見つかった場合は LzssOutputStream.createSearchReturn によって生成された一致位置と一致長の情報を持つ値、 一致が見つからなかった場合は LzssOutputStream.NOMATCH。

slide

public void slide()
TextBuffer内の position までのデータを前方へ移動する際、 それに応じて ハッシュと二分木を使用した検索機構を構成するデータも TextBuffer内のデータと矛盾しないように前方へ移動する処理を行う。
Specified by:
slide in interface LzssSearchMethod

When you found typographical errors or omissions, Please mail to cqw10305@nifty.com
The company name and product name which are used in this document, it is the trademark or registered trademark of each company generally.
Copyright © 2001-2002 Michel Ishizuka. All Rights Reserved.