1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
//start of HashShort.java
//TEXT_STYLE:CODE=Shift_JIS(Japanese):RET_CODE=CRLF
/**
* HashShort.java
*
* Copyright (C) 2002 Michel Ishizuka All rights reserved.
*
* ȉ̏ɓӂȂ\[XƃoCi`̍ĔzzƎgp
* ύX̗Lɂ炸B
*
* PD\[XR[h̍ĔzzɂĒ쌠\ ̏̃Xg
* щL̐ێȂĂ͂ȂȂB
*
* QDoCi`̍ĔzzɂĒ쌠\ ̏̃Xg
* щL̐gp ̑̔zz
* ܂ގɋLqȂȂȂB
*
* ̃\tgEFA͐Β˔ڂɂĖۏŒA̖
* IBłƂۏAilLƂۏɂƂǂ܂炸A
* Ȃ閾IшÎIȕۏȂB
* Β˔ڂ ̃\tgEFA̎gpɂ钼ړIAԐړIA
* IAȁAT^IȁA邢͕KRIȑQ(gpɂf[^
* AƖ̒f〈܂Ăv̈⎸Ai
* T[rX̓l邪AĂꂾɌ肳Ȃ
* Q)ɑāAȂ鎖Ԃ̌ƂȂƂĂA_̐
* C△ߎӔC܂ ȂӔC낤ƂAƂꂪs
* ŝׂ߂łƂĂA܂͂̂悤ȑQ̉\
* ĂƂĂ̐ӔCȂ̂ƂB
*/
package jp.gr.java_conf.dangan.util.lha;
//import classes and interfaces
import jp.gr.java_conf.dangan.util.lha.HashMethod;
//import exceptions
/**
* f[^p^̐擪2oCg
* 0 ` 4095 ̃nbVlnbVB
*
* <pre>
* -- revision history --
* $Log: HashShort.java,v $
* Revision 1.0 2002/08/05 00:00:00 dangan
* add to version control
* [change]
* HashMethod ̃C^tFCXύXɂ킹ăCetFCXύXB
* [maintanance]
* \[X
* ^up~
* CZX̏C
*
* </pre>
*
* @author $Author: dangan $
* @version $Revision: 1.0 $
*/
public class HashShort implements HashMethod{
//------------------------------------------------------------------
// instance field
//------------------------------------------------------------------
// private byte[] TextBuffer
//------------------------------------------------------------------
/**
* LZSSk{߂̃obt@B
* Ö͎A
* 㔼͈k{߂̃f[^̓obt@B
* HashMethod̎ł Hashl̐̂߂̓ǂݍ݂ɂ̂ݎgpB
*/
private byte[] TextBuffer;
//------------------------------------------------------------------
// constructor
//------------------------------------------------------------------
// private HashShort()
// public HashShort( byte[] TextBuffer )
//------------------------------------------------------------------
/**
* ftHgRXgN^B
* gps
*/
private HashShort(){ }
/**
* f[^p^̐擪2oCg 0x000 ` 0xFFF ܂ł̒l
* nbV\zB
*
* @param TextBuffer LZSSkp̃obt@B
* Hashl̂ߓǂݍݗpɎgpB
*/
public HashShort( byte[] TextBuffer ){
this.TextBuffer = TextBuffer;
}
//------------------------------------------------------------------
// method of jp.gr.java_conf.dangan.util.lha.HashMethod
//------------------------------------------------------------------
// public int hash( int position )
// public int hashRequires()
// public int tableSize()
//------------------------------------------------------------------
/**
* nbVB
* RXgN^œnꂽ TextBuffer position
* f[^p^ hashlB
*
* @param position f[^p^̊Jnʒu
*
* @return nbVl
*/
public int hash( int position ){
return ( ( ( ( this.TextBuffer[ position + 1 ] & 0x0F ) << 8 )
| ( ( this.TextBuffer[ position + 1 ] & 0xFF ) >> 4 ) )
^ ( ( this.TextBuffer[ position ] & 0xFF ) << 2 ) );
}
/**
* nbVnbVl邽߂ɎgpoCgB<br>
* ̃nbV̓f[^p^̐擪 2 oCg̃f[^
* nbVl邽߁Ã\bh͏ 2 ԂB
*
* @return 2
*/
public int hashRequires(){
return 2;
}
/**
* nbVe[ũTCYB<br>
* ̃nbV 0x000 ` 0xFFF ܂ł̃nbVl邽
* ̃\bh͏ 0x1000(4096) ԂB
*
* @return 0x1000(4096)
*/
public int tableSize(){
return 0x1000;
}
}
//end of HashShort.java
|