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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753
|
//start of HashAndChainedListSearch.java
//TEXT_STYLE:CODE=Shift_JIS(Japanese):RET_CODE=CRLF
/**
* HashAndChainedListSearch.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.lang.reflect.Factory;
import jp.gr.java_conf.dangan.util.lha.HashMethod;
import jp.gr.java_conf.dangan.util.lha.HashDefault;
import jp.gr.java_conf.dangan.util.lha.LzssOutputStream;
import jp.gr.java_conf.dangan.util.lha.LzssSearchMethod;
//import exceptions
import java.io.IOException;
import java.lang.NoSuchMethodException;
import java.lang.ClassNotFoundException;
import java.lang.InstantiationException;
import java.lang.IllegalArgumentException;
import java.lang.reflect.InvocationTargetException;
import java.lang.Error;
import java.lang.NoSuchMethodError;
import java.lang.InstantiationError;
import java.lang.NoClassDefFoundError;
/**
* nbVƒPAXggčꂽ LzssSearchMethodB<br>
* ł邱Ƃɂ鍂sĂ邽߁A
* KŒv邱ƂoƂ͌ȂB<br>
*
* <pre>
* -- revision history --
* $Log: HashAndChainedListSearch.java,v $
* Revision 1.0 2002/08/05 00:00:00 dangan
* add to version control
* [change]
* LzssSearchMethod ̃C^tFCXύXɂ킹ăC^tFCXύX
* [improvement]
* ar940528 TEST5 ̎ɕύXB
* [maintenance]
* \[X
* ^up~
* CZX̏C
*
* </pre>
*
* @author $Author: dangan $
* @version $Revision: 1.0 $
*/
public class HashAndChainedListSearch implements LzssSearchMethod{
//------------------------------------------------------------------
// instance field
//------------------------------------------------------------------
// LZSS parameter
//------------------------------------------------------------------
// private int DictionarySize
// private int MaxMatch
// private int Threshold
//------------------------------------------------------------------
/**
* LZSSTCYB
*/
private int DictionarySize;
/**
* LZSSkɎgplB
* ővB
*/
private int MaxMatch;
/**
* LZSSkɎgp臒lB
* v ̒lȏłAkR[ho͂B
*/
private int Threshold;
//------------------------------------------------------------------
// instance field
//------------------------------------------------------------------
// text buffer
//------------------------------------------------------------------
// private byte[] TextBuffer
// private int DictionaryLimit
//------------------------------------------------------------------
/**
* LZSSk{߂̃obt@B
* Ö͎A
* 㔼͈k{߂̃f[^̓obt@B
* LzssSearchMethod̎ł͓ǂݍ݂̂B
*/
private byte[] TextBuffer;
/**
* ̌EʒuB
* TextBufferO̎̈Ƀf[^ꍇ
* ̈ɂs̃f[^(Javał0)gp
* Ĉkŝ}~B
*/
private int DictionaryLimit;
//------------------------------------------------------------------
// instance field
//------------------------------------------------------------------
// hash
//------------------------------------------------------------------
// private HashMethod hashMethod
// private int[] hashTable
// private char[] tooBigFlag
//------------------------------------------------------------------
/**
* nbV
*/
private HashMethod hashMethod;
/**
* nbVe[u
* Y̓nbVlAeTextBuffer̈ʒu
*/
private int[] hashTable;
/**
* nbVlf[^p^̘AXg̒
* ȏɂȂꍇɃZbgtOB
*
* boolean[] ɂƉ̂xȂ̂
* char[] Ƃ 16Z߂ĈB
* ꍇ [eBeB\bh
* isTooBig(), setTooBigFlag(), clearTooBigFlag() ĈB
*/
private char[] tooBigFlag;
//------------------------------------------------------------------
// instance field
//------------------------------------------------------------------
// cahined list
//------------------------------------------------------------------
// private int[] prev
// private int SearchLimitCount
//------------------------------------------------------------------
/**
* nbVlf[^p^Jnʒu
* PAXgB
*/
private int[] prev;
/**
* Ts̏lB
* ̉ȏ̒T͍sȂB
*/
private int SearchLimitCount;
//------------------------------------------------------------------
// constructor
//------------------------------------------------------------------
// private HashAndChainedListSearch()
// public HashAndChainedListSearch( int DictionarySize, int MaxMatch,
// int Threshold, byte[] TextBuffer )
// public HashAndChainedListSearch( int DictionarySize, int MaxMatch,
// int Threshold, byte[] TextBuffer,
// int SearchLimitCount )
// public HashAndChainedListSearch( int DictionarySize, int MaxMatch,
// int Threshold, byte[] TextBuffer,
// String HashMethodClassName )
// public HashAndChainedListSearch( int DictionarySize, int MaxMatch,
// int Threshold, byte[] TextBuffer,
// String HashMethodClassName,
// int SearchLimitCount )
//------------------------------------------------------------------
/**
* ftHgRXgN^B
* gpsB
*/
private HashAndChainedListSearch(){ }
/**
* nbVƘAXggp LzssSearchMethod \zB<br>
* nbVƒTs̏lɂ̓ftHĝ̂gpB<br>
*
* @param DictionarySize TCY
* @param MaxMatch Œv
* @param Threshold kAk臒l
* @param TextBuffer LZSSk{߂̃obt@
*/
public HashAndChainedListSearch( int DictionarySize,
int MaxMatch,
int Threshold,
byte[] TextBuffer ){
this( DictionarySize,
MaxMatch,
Threshold,
TextBuffer,
HashDefault.class.getName(),
256 );
}
/**
* nbVƘAXggp LzssSearchMethod \zB<br>
* nbVɂ̓ftHĝ̂gpB<br>
*
* @param DictionarySize TCY
* @param MaxMatch Œv
* @param Threshold kAk臒l
* @param TextBuffer LZSSk{߂̃obt@
* @param SearchLimitCount Ts̏
*
* @exception IllegalArgumentException
* SearchLimitCount 0ȉ̏ꍇ
*/
public HashAndChainedListSearch( int DictionarySize,
int MaxMatch,
int Threshold,
byte[] TextBuffer,
int SearchLimitCount ){
this( DictionarySize,
MaxMatch,
Threshold,
TextBuffer,
HashDefault.class.getName(),
SearchLimitCount );
}
/**
* nbVƘAXggp LzssSearchMethod \zB<br>
* Ts̏lɂ̓ftHĝ̂gpB<br>
*
* @param DictionarySize TCY
* @param MaxMatch Œv
* @param Threshold kAk臒l
* @param TextBuffer LZSSk{߂̃obt@
* @param HashMethodClassName HashNX
*
* @exception NoClassDefFoundError
* HashMethodClassName ŗ^ꂽNX
* ȂꍇB
* @exception InstantiationError
* HashMethodClassName ŗ^ꂽNX
* abstract class ł邽߃CX^XłȂꍇB
* @exception NoSuchMethodError
* HashMethodClassName ŗ^ꂽNX
* RXgN^ HashMethod( byte[] )Ȃꍇ
*/
public HashAndChainedListSearch( int DictionarySize,
int MaxMatch,
int Threshold,
byte[] TextBuffer,
String HashMethodClassName ){
this( DictionarySize,
MaxMatch,
Threshold,
TextBuffer,
HashMethodClassName,
256 );
}
/**
* nbVƘAXggp LzssSearchMethod \zB<br>
*
* @param DictionarySize TCY
* @param MaxMatch Œv
* @param Threshold kAk臒l
* @param TextBuffer LZSSk{߂̃obt@
* @param HashMethodClassName HashNX
* @param SearchLimitCount Ts̏
*
* @exception IllegalArgumentException
* SearchLimitCount 0ȉ̏ꍇ
* @exception NoClassDefFoundError
* HashMethodClassName ŗ^ꂽNX
* ȂꍇB
* @exception InstantiationError
* HashMethodClassName ŗ^ꂽNX
* abstract class ł邽߃CX^XłȂꍇB
* @exception NoSuchMethodError
* HashMethodClassName ŗ^ꂽNX
* RXgN^ HashMethod( byte[] )Ȃꍇ
*/
public HashAndChainedListSearch( int DictionarySize,
int MaxMatch,
int Threshold,
byte[] TextBuffer,
String HashMethodClassName,
int SearchLimitCount ){
if( 0 < SearchLimitCount ){
this.DictionarySize = DictionarySize;
this.MaxMatch = MaxMatch;
this.Threshold = Threshold;
this.TextBuffer = TextBuffer;
this.DictionaryLimit = this.DictionarySize;
this.SearchLimitCount = SearchLimitCount;
try{
this.hashMethod = (HashMethod)Factory.createInstance(
HashMethodClassName,
new Object[]{ TextBuffer } );
}catch( ClassNotFoundException exception ){
throw new NoClassDefFoundError( exception.getMessage() );
}catch( InvocationTargetException exception ){
throw new Error( exception.getTargetException().getMessage() );
}catch( NoSuchMethodException exception ){
throw new NoSuchMethodError( exception.getMessage() );
}catch( InstantiationException exception ){
throw new InstantiationError( exception.getMessage() );
}
// nbVe[u
this.hashTable = new int[ this.hashMethod.tableSize() ];
for( int i = 0 ; i < this.hashTable.length ; i++ ){
this.hashTable[i] = -1;
}
// AXg
this.prev = new int[ this.DictionarySize ];
for( int i = 0 ; i < this.prev.length ; i++ ){
this.prev[i] = -1;
}
this.tooBigFlag = new char[ this.hashMethod.tableSize() >> 4 ];
}else{
throw new IllegalArgumentException( "SearchLimitCount must be 1 or more." );
}
}
//------------------------------------------------------------------
// method jp.gr.java_conf.dangan.util.lha.LzssSearchMethod
//------------------------------------------------------------------
// public void put( int position )
// public int searchAndPut( int position )
// public int search( int position, int lastPutPos )
// public void slide( int slideWidth, int slideEnd )
// public int putRequires()
//------------------------------------------------------------------
/**
* position n܂f[^p^
* nbVƘAXg琬錟@\ɓo^B<br>
*
* @param position TextBuffer̃f[^p^̊Jnʒu
*/
public void put( int position ){
int hash = this.hashMethod.hash( position );
this.prev[ position & ( this.DictionarySize - 1 ) ] = this.hashTable[ hash ];
this.hashTable[ hash ] = position;
}
/**
* nbVƘAXg琬錟@\ɓo^ꂽ
* f[^p^ position n܂f[^p^
* Œ̈v̂A
* position n܂f[^p^
* nbVƘAXg琬錟@\ɓo^B<br>
*
* @param position TextBuffer̃f[^p^̊JnʒuB
*
* @return vꍇ
* LzssOutputStream.createSearchReturn
* ɂĐꂽvʒuƈv̏lA
* vȂꍇ
* LzssOutputStream.NOMATCHB
*
* @see LzssOutputStream#createSearchReturn(int,int)
* @see LzssOutputStream#NOMATCH
*/
public int searchAndPut( int position ){
int matchlen = this.Threshold - 1;
int matchpos = position;
int maxmatch = this.MaxMatch;
int scanlimit = Math.max( this.DictionaryLimit,
position - this.DictionarySize );
//------------------------------------------------------------------
// AXg̒ꍇ offset gp
// AXg̒ZnbVlgB
int poshash = this.hashMethod.hash( position );
int offhash = poshash;
int offset = 0;
while( this.isTooBig( offhash )
&& offset < this.MaxMatch - this.hashMethod.hashRequires() ){
offset++;
offhash = this.hashMethod.hash( position + offset );
}
//------------------------------------------------------------------
// C[v
// ő offhash poshash n܂ 2̘AXg𑖍B
byte[] buf = this.TextBuffer;
int max = position + this.MaxMatch;
int s = 0;
int p = 0;
int len = 0;
while( true ){
int scanpos = this.hashTable[ offhash ];
int searchCount = this.SearchLimitCount;
while( scanlimit <= scanpos - offset && 0 < --searchCount ){
if( buf[ scanpos + matchlen - offset ]
== buf[ position + matchlen ] ){
s = scanpos - offset;
p = position;
while( buf[ s ] == buf[ p ] ){
s++;
p++;
if( max <= p ) break;
}
len = p - position;
if( matchlen < len ){
matchpos = scanpos - offset;
matchlen = len;
if( max <= p ) break;
}
}
scanpos = this.prev[ scanpos & ( this.DictionarySize - 1 ) ];
}
if( searchCount <= 0 ){
this.setTooBigFlag( offhash );
}else if( scanpos < scanlimit ){
this.clearTooBigFlag( offhash );
}
if( 0 < offset
&& matchlen < this.hashMethod.hashRequires() + offset ){
offset = 0;
maxmatch = this.hashMethod.hashRequires() + offset - 1;
max = position + maxmatch;
offhash = poshash;
}else{
break;
}
}
//------------------------------------------------------------------
// nbVƘAXggp@\
// position n܂f[^p^o^B
this.prev[ position & ( this.DictionarySize - 1 ) ] = this.hashTable[ poshash ];
this.hashTable[ poshash ] = position;
//------------------------------------------------------------------
// ŒvĂяoɕԂB
if( this.Threshold <= matchlen ){
return LzssOutputStream.createSearchReturn( matchlen, matchpos );
}else{
return LzssOutputStream.NOMATCH;
}
}
/**
* nbVƘAXggp@\ɓo^ꂽ
* f[^p^ position n܂f[^p^
* Œ̈v̂B<br>
*
* @param position TextBuffer̃f[^p^̊JnʒuB
* @param lastPutPos Ōɓo^f[^p^̊JnʒuB
*
* @return vꍇ
* LzssOutputStream.createSearchReturn
* ɂĐꂽvʒuƈv̏lA
* vȂꍇ
* LzssOutputStream.NOMATCHB
*
* @see LzssOutputStream#createSearchReturn(int,int)
* @see LzssOutputStream#NOMATCH
*/
public int search( int position, int lastPutPos ){
//------------------------------------------------------------------
// nbVƘAXgɂ錟@\ɓo^ĂȂ
// f[^p^PȒŌB
int matchlen = this.Threshold - 1;
int matchpos = position;
int scanpos = position - 1;
int scanlimit = Math.max( this.DictionaryLimit, lastPutPos );
byte[] buf = this.TextBuffer;
int max = Math.min( this.TextBuffer.length,
position + this.MaxMatch );
int s = 0;
int p = 0;
int len = 0;
while( scanlimit < scanpos ){
s = scanpos;
p = position;
while( buf[ s ] == buf[ p ] ){
s++;
p++;
if( max <= p ) break;
}
if( matchlen < len ){
matchpos = scanpos;
matchlen = len;
}
scanpos--;
}
//------------------------------------------------------------------
// nbVƘAXggp@\ 猟B
if( this.hashMethod.hashRequires() < this.TextBuffer.length - position ){
int maxmatch = this.MaxMatch;
scanlimit = Math.max( this.DictionaryLimit,
position - this.DictionarySize );
// AXg̒ꍇ offset gp
// AXg̒ZnbVlgB
int poshash = this.hashMethod.hash( position );
int offhash = poshash;
int offset = 0;
while( this.isTooBig( offhash )
&& offset < this.MaxMatch - this.hashMethod.hashRequires() ){
offset++;
offhash = this.hashMethod.hash( position + offset );
}
// C[v
// ő offhash poshash n܂ 2̘AXg𑖍B
while(true){
int searchCount = this.SearchLimitCount;
scanpos = this.hashTable[ offhash ];
while( scanlimit <= scanpos - offset && 0 < --searchCount ){
if( buf[ scanpos + matchlen - offset ]
== buf[ position + matchlen ] ){
s = scanpos - offset;
p = position;
while( buf[ s ] == buf[ p ] ){
s++;
p++;
if( max <= p ) break;
}
len = p - position;
if( matchlen < len ){
matchpos = scanpos - offset;
matchlen = len;
if( max <= p ) break;
}
}
scanpos = this.prev[ scanpos & ( this.DictionarySize - 1 ) ];
}
if( searchCount <= 0 ){
this.setTooBigFlag( offhash );
}else if( scanpos < scanlimit ){
this.clearTooBigFlag( offhash );
}
if( 0 < offset
&& matchlen < this.hashMethod.hashRequires() + offset ){
offset = 0;
maxmatch = this.hashMethod.hashRequires() + offset - 1;
max = Math.min( this.TextBuffer.length,
position + maxmatch );
offhash = poshash;
}else{
break;
}
}
}
//------------------------------------------------------------------
// ŒvĂяoɕԂB
if( this.Threshold <= matchlen ){
return LzssOutputStream.createSearchReturn( matchlen, matchpos );
}else{
return LzssOutputStream.NOMATCH;
}
}
/**
* TextBufferposition܂ł̃f[^
* OֈړہAɉ SearchMethod
* f[^ TextBuffer̃f[^ƖȂ悤
* Oֈړ鏈sB
*/
public void slide(){
this.DictionaryLimit = Math.max( 0, this.DictionaryLimit - this.DictionarySize );
for( int i = 0 ; i < this.hashTable.length ; i++ ){
int pos = this.hashTable[i] - this.DictionarySize;
this.hashTable[i] = ( 0 <= pos ? pos : -1 );
}
for( int i = 0 ; i < this.prev.length ; i++ ){
int pos = this.prev[i] - this.DictionarySize;
this.prev[i] = ( 0 <= pos ? pos : -1 );;
}
}
/**
* put() LzssSearchMethodɃf[^
* o^ƂɎgpf[^ʂB
* HashAndChainedListSearch ł́A
* ŎgpĂ HashMethod ̎
* hash() ̂߂ɕKvƂf[^
* ( HashMethod.hashRequires() ̖߂l ) ԂB
*
* @return ŎgpĂ HashMethod ̎
* hash() ̂߂ɕKvƂf[^
*/
public int putRequires(){
return this.hashMethod.hashRequires();
}
//------------------------------------------------------------------
// method of ImprovedLzssSearchMethod
//------------------------------------------------------------------
// public int searchAndPut( int position, int[] matchposs )
//------------------------------------------------------------------
/**
* ǂ LZSS k̂߂̑I searchAndPut()B
* ႦΈv 3, vʒu 4 v 4, vʒu 1024 ł
* v 3, vʒu 4 + k1 ̕o̓rbg
* ȂȂ鎖B̂悤ȏꍇɑΏ邽߈v
* positionɈԋ߂vʒuB
*
* @param position Ώۂ̃f[^p^̊Jnʒu
* @param matchposs vʒu̗i[ĕԂ߂̔z<br>
* matchpos[0] ɂ v Threshold ̈vʒuA<br>
* matchpos[1] ɂ v Threshold + 1 ̈vʒui[B<br>
* vȂꍇɂ LzssOutputStream.NOMATCH i[B
*
* @return vꍇ
* LzssOutputStream.createSearchReturn Őꂽ SearchReturn ԂB<br>
* vȂꍇ LzssOutputStream.NOMATCH ԂB<br>
*/
public int searchAndPut( int position, int[] matchposs ){
int matchlen = this.Threshold - 1;
int matchpos = position;
int maxmatch = this.MaxMatch;
int scanlimit = Math.max( this.DictionaryLimit,
position - this.DictionarySize );
int searchCount = this.SearchLimitCount;
for( int i = 0 ; i < matchposs.length ; i++ )
matchposs[i] = LzssOutputStream.NOMATCH;
int scanpos = this.hashTable[ this.hashMethod.hash( position ) ];
while( scanlimit < scanpos && 0 < searchCount-- ){
if( this.TextBuffer[ scanpos + matchlen ]
== this.TextBuffer[ position + matchlen ] ){
int len = 0;
while( this.TextBuffer[ scanpos + len ]
== this.TextBuffer[ position + len ] ){
if( maxmatch <= ++len ) break;
}
if( matchlen < len ){
int i = matchlen + 1 - this.Threshold;
int end = Math.min( len + 1 - this.Threshold, matchposs.length );
while( i < end ) matchposs[ i++ ] = scanpos;
matchpos = scanpos;
matchlen = len;
if( maxmatch <= len )
break;
}
}
scanpos = this.prev[ scanpos & ( this.DictionarySize - 1 ) ];
}
this.put( position );
if( matchpos < position )
return LzssOutputStream.createSearchReturn( matchlen, matchpos );
else
return LzssOutputStream.NOMATCH;
}
//------------------------------------------------------------------
// local methods
//------------------------------------------------------------------
// too big flag
//------------------------------------------------------------------
// private int isTooBig( int hash )
// private void setTooBigFlag( int hash )
// private void clearTooBigFlag( int hash )
//------------------------------------------------------------------
/**
* hash ̘AXg臒lĂ邩B
*
* @param hash nbVl
*
* @return AXg̒臒lĂȂ true
* ĂȂ false
*/
private boolean isTooBig( int hash ){
return 0 != ( this.tooBigFlag[ hash >> 4 ] & ( 1 << ( hash & 0x0F ) ) );
}
/**
* hash ̘AXg臒l
* tOZbgB
*
* @param hash too big tOZbgnbVl
*/
private void setTooBigFlag( int hash ){
this.tooBigFlag[ hash >> 4 ] |= 1 << ( hash & 0x0F );
}
/**
* hash ̘AXg臒lĂ鎖
* tONAB
*
* @param hash too big tONAnbVl
*/
private void clearTooBigFlag( int hash ){
this.tooBigFlag[ hash >> 4 ] &= ~( 1 << ( hash & 0x0F ) );
}
}
//end of HashAndChainedListSearch.java
|