Advertisement
flok99

Untitled

Jul 24th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1.     final long hashMask = 0x7fffffffffffffffl;
  2.     long nTableElements = 11671106;
  3.  
  4.         public void put(long hash, int score, int depth) {
  5.                 // mask to make sure it is a positive value
  6.                 hash &= hashMask;
  7.  
  8.         // make sure no other thread fiddles with it
  9.                 int lockIndex = (int)(hash & 255);
  10.                 locks[lockIndex].acquireUninterruptibly();
  11.  
  12.                 int arrayIndex = (int)(hash % nTableElements);
  13.                 hashes[arrayIndex] = hash;
  14.                 scores[arrayIndex] = score;
  15.                 depths[arrayIndex] = depth;
  16.  
  17.                 locks[lockIndex].release();
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement