1 24 package org.archive.util.fingerprint; 25 26 27 28 36 public class LongFPSetCache extends MemLongFPSet { 37 38 private static final long serialVersionUID = -5307436423975825566L; 39 40 long sweepHand = 0; 41 42 public LongFPSetCache() { 43 super(); 44 } 45 46 public LongFPSetCache(int capacityPowerOfTwo, float loadFactor) { 47 super(capacityPowerOfTwo, loadFactor); 48 } 49 50 protected void noteAccess(long index) { 51 if(slots[(int)index]<Byte.MAX_VALUE) { 52 slots[(int)index]++; 53 } 54 } 55 56 protected void makeSpace() { 57 discard(1); 58 } 59 60 private void discard(int i) { 61 int toDiscard = i; 62 while(toDiscard>0) { 63 if(slots[(int)sweepHand]==0) { 64 removeAt(sweepHand); 65 toDiscard--; 66 } else { 67 if (slots[(int)sweepHand]>0) { 68 slots[(int)sweepHand]--; 69 } 70 } 71 sweepHand++; 72 if (sweepHand==slots.length) { 73 sweepHand = 0; 74 } 75 } 76 } 77 } 78 | Popular Tags |