public class DynamicHuffman
extends java.lang.Object
implements java.lang.Cloneable
-- revision history -- $Log: DynamicHuffman.java,v $ Revision 1.0 2002/07/24 00:00:00 dangan add to version control [bug fix] addLeaf() で葉の数が 1 から 2へと増加するときに 最初からあった葉の重さが 1 だと決め付けていた。 [change] コンストラクタ DynamicHuffman( int, int ) で 開始時のハフマン木のサイズでなく 開始時の葉の数を渡すように変更。 [maintenance] ソース整備 タブ廃止 ライセンス文の変更
Modifier and Type | Field and Description |
---|---|
static int |
ROOT
ハフマン木のルートを示す。
|
Constructor and Description |
---|
DynamicHuffman(int count)
コンストラクタ
|
DynamicHuffman(int max,
int first)
コンストラクタ
|
Modifier and Type | Method and Description |
---|---|
void |
addLeaf(int code)
ハフマン木に code を示す葉を追加する。
|
int |
childNode(int node)
ノードが葉でないノードなら子ノードのノード番号、
ノードが葉ならノードの持つデータを全ビット反転したものを得る。
子ノードのノード番号は兄弟特性と利用するため、
node の 0 の子ノードの場合 childNode( node ) node の 1 の子ノードの場合 childNode( node ) - 1 となる。 |
java.lang.Object |
clone()
このオブジェクトの現在の状態を持つコピーを作成して返す。
|
int |
codeToNode(int code)
データからノード番号を得る。
|
int |
parentNode(int node)
node の親ノードのノード番号を得る。
|
void |
update(int code)
code の重みが増すようにハフマン木を更新する。
|
public static final int ROOT
public DynamicHuffman(int count)
count
- 葉の数public DynamicHuffman(int max, int first)
max
- 葉の最大数start
- 開始時の葉の数public java.lang.Object clone()
clone
in class java.lang.Object
public int codeToNode(int code)
code
- データpublic int childNode(int node)
node
- ノードpublic int parentNode(int node)
node
- ノードpublic void update(int code)
code
- 重みを増やす葉public void addLeaf(int code)
code
- 葉の示す符号java.lang.IllegalStateException
- ハフマン木が十分に大きいため
葉が追加できない場合
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.