コード例 #1
0
/*      */   public Short put(Long ok, Short ov) {
/*  262 */     short v = ov.shortValue();
/*  263 */     long k = ok.longValue();
/*      */ 
/*  265 */     int pos = (int)HashCommon.murmurHash3(k) & this.mask;
/*      */ 
/*  267 */     while (this.used[pos] != 0) {
/*  268 */       if (this.key[pos] == k) {
/*  269 */         Short oldValue = Short.valueOf(this.value[pos]);
/*  270 */         this.value[pos] = v;
/*  271 */         return oldValue;
/*      */       }
/*  273 */       pos = pos + 1 & this.mask;
/*      */     }
/*  275 */     this.used[pos] = true;
/*  276 */     this.key[pos] = k;
/*  277 */     this.value[pos] = v;
/*  278 */     if (this.size == 0) {
/*  279 */       this.first = (this.last = pos);
/*      */ 
/*  281 */       this.link[pos] = -1L;
/*      */     }
/*      */     else {
/*  284 */       this.link[this.last] ^= (this.link[this.last] ^ pos & 0xFFFFFFFF) & 0xFFFFFFFF;
/*  285 */       this.link[pos] = ((this.last & 0xFFFFFFFF) << 32 | 0xFFFFFFFF);
/*  286 */       this.last = pos;
/*      */     }
/*  288 */     if (++this.size >= this.maxFill) rehash(HashCommon.arraySize(this.size + 1, this.f));
/*      */ 
/*  290 */     return null;
/*      */   }
コード例 #2
0
/*      */   public Character put(Float ok, Character ov) {
/*  262 */     char v = ov.charValue();
/*  263 */     float k = ok.floatValue();
/*      */ 
/*  265 */     int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & this.mask;
/*      */ 
/*  267 */     while (this.used[pos] != 0) {
/*  268 */       if (this.key[pos] == k) {
/*  269 */         Character oldValue = Character.valueOf(this.value[pos]);
/*  270 */         this.value[pos] = v;
/*  271 */         return oldValue;
/*      */       }
/*  273 */       pos = pos + 1 & this.mask;
/*      */     }
/*  275 */     this.used[pos] = true;
/*  276 */     this.key[pos] = k;
/*  277 */     this.value[pos] = v;
/*  278 */     if (this.size == 0) {
/*  279 */       this.first = (this.last = pos);
/*      */ 
/*  281 */       this.link[pos] = -1L;
/*      */     }
/*      */     else {
/*  284 */       this.link[this.last] ^= (this.link[this.last] ^ pos & 0xFFFFFFFF) & 0xFFFFFFFF;
/*  285 */       this.link[pos] = ((this.last & 0xFFFFFFFF) << 32 | 0xFFFFFFFF);
/*  286 */       this.last = pos;
/*      */     }
/*  288 */     if (++this.size >= this.maxFill) rehash(HashCommon.arraySize(this.size + 1, this.f));
/*      */ 
/*  290 */     return null;
/*      */   }
コード例 #3
0
/*      */   public char putAndMoveToLast(float k, char v)
/*      */   {
/*  511 */     float[] key = this.key;
/*  512 */     boolean[] used = this.used;
/*  513 */     int mask = this.mask;
/*      */ 
/*  515 */     int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & mask;
/*      */ 
/*  517 */     while (used[pos] != 0) {
/*  518 */       if (k == key[pos]) {
/*  519 */         char oldValue = this.value[pos];
/*  520 */         this.value[pos] = v;
/*  521 */         moveIndexToLast(pos);
/*  522 */         return oldValue;
/*      */       }
/*  524 */       pos = pos + 1 & mask;
/*      */     }
/*  526 */     used[pos] = true;
/*  527 */     key[pos] = k;
/*  528 */     this.value[pos] = v;
/*  529 */     if (this.size == 0) {
/*  530 */       this.first = (this.last = pos);
/*      */ 
/*  532 */       this.link[pos] = -1L;
/*      */     }
/*      */     else {
/*  535 */       this.link[this.last] ^= (this.link[this.last] ^ pos & 0xFFFFFFFF) & 0xFFFFFFFF;
/*  536 */       this.link[pos] = ((this.last & 0xFFFFFFFF) << 32 | 0xFFFFFFFF);
/*  537 */       this.last = pos;
/*      */     }
/*  539 */     if (++this.size >= this.maxFill) rehash(HashCommon.arraySize(this.size, this.f));
/*      */ 
/*  541 */     return this.defRetValue;
/*      */   }
コード例 #4
0
/*     */   protected void rehash(int newN)
/*     */   {
/* 736 */     int i = 0;
/* 737 */     boolean[] used = this.used;
/*     */ 
/* 739 */     Object[] key = this.key;
/* 740 */     double[] value = this.value;
/* 741 */     int newMask = newN - 1;
/* 742 */     Object[] newKey = (Object[])new Object[newN];
/* 743 */     double[] newValue = new double[newN];
/* 744 */     boolean[] newUsed = new boolean[newN];
/* 745 */     for (int j = this.size; j-- != 0; ) {
/* 746 */       while (used[i] == 0) i++;
/* 747 */       Object k = key[i];
/* 748 */       int pos = HashCommon.murmurHash3(this.strategy.hashCode(k)) & newMask;
/* 749 */       while (newUsed[pos] != 0) pos = pos + 1 & newMask;
/* 750 */       newUsed[pos] = true;
/* 751 */       newKey[pos] = k;
/* 752 */       newValue[pos] = value[i];
/* 753 */       i++;
/*     */     }
/* 755 */     this.n = newN;
/* 756 */     this.mask = newMask;
/* 757 */     this.maxFill = HashCommon.maxFill(this.n, this.f);
/* 758 */     this.key = newKey;
/* 759 */     this.value = newValue;
/* 760 */     this.used = newUsed;
/*     */   }
コード例 #5
0
/*      */   public char put(float k, char v)
/*      */   {
/*  234 */     int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & this.mask;
/*      */ 
/*  236 */     while (this.used[pos] != 0) {
/*  237 */       if (this.key[pos] == k) {
/*  238 */         char oldValue = this.value[pos];
/*  239 */         this.value[pos] = v;
/*  240 */         return oldValue;
/*      */       }
/*  242 */       pos = pos + 1 & this.mask;
/*      */     }
/*  244 */     this.used[pos] = true;
/*  245 */     this.key[pos] = k;
/*  246 */     this.value[pos] = v;
/*  247 */     if (this.size == 0) {
/*  248 */       this.first = (this.last = pos);
/*      */ 
/*  250 */       this.link[pos] = -1L;
/*      */     }
/*      */     else {
/*  253 */       this.link[this.last] ^= (this.link[this.last] ^ pos & 0xFFFFFFFF) & 0xFFFFFFFF;
/*  254 */       this.link[pos] = ((this.last & 0xFFFFFFFF) << 32 | 0xFFFFFFFF);
/*  255 */       this.last = pos;
/*      */     }
/*  257 */     if (++this.size >= this.maxFill) rehash(HashCommon.arraySize(this.size + 1, this.f));
/*      */ 
/*  259 */     return this.defRetValue;
/*      */   }
コード例 #6
0
/*     */   protected void rehash(int newN)
/*     */   {
/* 729 */     int i = 0;
/* 730 */     boolean[] used = this.used;
/*     */ 
/* 732 */     long[] key = this.key;
/* 733 */     byte[] value = this.value;
/* 734 */     int newMask = newN - 1;
/* 735 */     long[] newKey = new long[newN];
/* 736 */     byte[] newValue = new byte[newN];
/* 737 */     boolean[] newUsed = new boolean[newN];
/* 738 */     for (int j = this.size; j-- != 0; ) {
/* 739 */       while (used[i] == 0) i++;
/* 740 */       long k = key[i];
/* 741 */       int pos = (int)HashCommon.murmurHash3(k) & newMask;
/* 742 */       while (newUsed[pos] != 0) pos = pos + 1 & newMask;
/* 743 */       newUsed[pos] = true;
/* 744 */       newKey[pos] = k;
/* 745 */       newValue[pos] = value[i];
/* 746 */       i++;
/*     */     }
/* 748 */     this.n = newN;
/* 749 */     this.mask = newMask;
/* 750 */     this.maxFill = HashCommon.maxFill(this.n, this.f);
/* 751 */     this.key = newKey;
/* 752 */     this.value = newValue;
/* 753 */     this.used = newUsed;
/*     */   }
コード例 #7
0
/*      */   public short putAndMoveToLast(long k, short v)
/*      */   {
/*  551 */     long[] key = this.key;
/*  552 */     boolean[] used = this.used;
/*  553 */     int mask = this.mask;
/*      */ 
/*  555 */     int pos = (int)HashCommon.murmurHash3(k) & mask;
/*      */ 
/*  557 */     while (used[pos] != 0) {
/*  558 */       if (k == key[pos]) {
/*  559 */         short oldValue = this.value[pos];
/*  560 */         this.value[pos] = v;
/*  561 */         moveIndexToLast(pos);
/*  562 */         return oldValue;
/*      */       }
/*  564 */       pos = pos + 1 & mask;
/*      */     }
/*  566 */     used[pos] = true;
/*  567 */     key[pos] = k;
/*  568 */     this.value[pos] = v;
/*  569 */     if (this.size == 0) {
/*  570 */       this.first = (this.last = pos);
/*      */ 
/*  572 */       this.link[pos] = -1L;
/*      */     }
/*      */     else {
/*  575 */       this.link[this.last] ^= (this.link[this.last] ^ pos & 0xFFFFFFFF) & 0xFFFFFFFF;
/*  576 */       this.link[pos] = ((this.last & 0xFFFFFFFF) << 32 | 0xFFFFFFFF);
/*  577 */       this.last = pos;
/*      */     }
/*  579 */     if (++this.size >= this.maxFill) rehash(HashCommon.arraySize(this.size, this.f));
/*      */ 
/*  581 */     return this.defRetValue;
/*      */   }
コード例 #8
0
/*      */   public short putAndMoveToFirst(long k, short v)
/*      */   {
/*  512 */     long[] key = this.key;
/*  513 */     boolean[] used = this.used;
/*  514 */     int mask = this.mask;
/*      */ 
/*  516 */     int pos = (int)HashCommon.murmurHash3(k) & mask;
/*      */ 
/*  518 */     while (used[pos] != 0) {
/*  519 */       if (k == key[pos]) {
/*  520 */         short oldValue = this.value[pos];
/*  521 */         this.value[pos] = v;
/*  522 */         moveIndexToFirst(pos);
/*  523 */         return oldValue;
/*      */       }
/*  525 */       pos = pos + 1 & mask;
/*      */     }
/*  527 */     used[pos] = true;
/*  528 */     key[pos] = k;
/*  529 */     this.value[pos] = v;
/*  530 */     if (this.size == 0) {
/*  531 */       this.first = (this.last = pos);
/*      */ 
/*  533 */       this.link[pos] = -1L;
/*      */     }
/*      */     else {
/*  536 */       this.link[this.first] ^= (this.link[this.first] ^ (pos & 0xFFFFFFFF) << 32) & 0x0;
/*  537 */       this.link[pos] = (0x0 | this.first & 0xFFFFFFFF);
/*  538 */       this.first = pos;
/*      */     }
/*  540 */     if (++this.size >= this.maxFill) rehash(HashCommon.arraySize(this.size, this.f));
/*      */ 
/*  542 */     return this.defRetValue;
/*      */   }
コード例 #9
0
/*      */   public short add(long k, short incr)
/*      */   {
/*  305 */     int pos = (int)HashCommon.murmurHash3(k) & this.mask;
/*      */ 
/*  307 */     while (this.used[pos] != 0) {
/*  308 */       if (this.key[pos] == k) {
/*  309 */         short oldValue = this.value[pos];
/*      */         int tmp49_47 = pos;
/*      */         short[] tmp49_44 = this.value; tmp49_44[tmp49_47] = ((short)(tmp49_44[tmp49_47] + incr));
/*  311 */         return tmp49_47;
/*      */       }
/*  313 */       pos = pos + 1 & this.mask;
/*      */     }
/*  315 */     this.used[pos] = true;
/*  316 */     this.key[pos] = k;
/*  317 */     this.value[pos] = ((short)(this.defRetValue + incr));
/*  318 */     if (this.size == 0) {
/*  319 */       this.first = (this.last = pos);
/*      */ 
/*  321 */       this.link[pos] = -1L;
/*      */     }
/*      */     else {
/*  324 */       this.link[this.last] ^= (this.link[this.last] ^ pos & 0xFFFFFFFF) & 0xFFFFFFFF;
/*  325 */       this.link[pos] = ((this.last & 0xFFFFFFFF) << 32 | 0xFFFFFFFF);
/*  326 */       this.last = pos;
/*      */     }
/*  328 */     if (++this.size >= this.maxFill) rehash(HashCommon.arraySize(this.size + 1, this.f));
/*      */ 
/*  330 */     return this.defRetValue;
/*      */   }
コード例 #10
0
/*      */   public char putAndMoveToFirst(float k, char v)
/*      */   {
/*  472 */     float[] key = this.key;
/*  473 */     boolean[] used = this.used;
/*  474 */     int mask = this.mask;
/*      */ 
/*  476 */     int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & mask;
/*      */ 
/*  478 */     while (used[pos] != 0) {
/*  479 */       if (k == key[pos]) {
/*  480 */         char oldValue = this.value[pos];
/*  481 */         this.value[pos] = v;
/*  482 */         moveIndexToFirst(pos);
/*  483 */         return oldValue;
/*      */       }
/*  485 */       pos = pos + 1 & mask;
/*      */     }
/*  487 */     used[pos] = true;
/*  488 */     key[pos] = k;
/*  489 */     this.value[pos] = v;
/*  490 */     if (this.size == 0) {
/*  491 */       this.first = (this.last = pos);
/*      */ 
/*  493 */       this.link[pos] = -1L;
/*      */     }
/*      */     else {
/*  496 */       this.link[this.first] ^= (this.link[this.first] ^ (pos & 0xFFFFFFFF) << 32) & 0x0;
/*  497 */       this.link[pos] = (0x0 | this.first & 0xFFFFFFFF);
/*  498 */       this.first = pos;
/*      */     }
/*  500 */     if (++this.size >= this.maxFill) rehash(HashCommon.arraySize(this.size, this.f));
/*      */ 
/*  502 */     return this.defRetValue;
/*      */   }
コード例 #11
0
/*     */   protected void rehash(int newN)
/*     */   {
/* 716 */     int i = 0;
/* 717 */     boolean[] used = this.used;
/*     */ 
/* 719 */     Object[] key = this.key;
/* 720 */     int[] value = this.value;
/* 721 */     int newMask = newN - 1;
/* 722 */     Object[] newKey = (Object[])new Object[newN];
/* 723 */     int[] newValue = new int[newN];
/* 724 */     boolean[] newUsed = new boolean[newN];
/* 725 */     for (int j = this.size; j-- != 0; ) {
/* 726 */       while (used[i] == 0) i++;
/* 727 */       Object k = key[i];
/* 728 */       int pos = (k == null ? 142593372 : HashCommon.murmurHash3(System.identityHashCode(k))) & newMask;
/* 729 */       while (newUsed[pos] != 0) pos = pos + 1 & newMask;
/* 730 */       newUsed[pos] = true;
/* 731 */       newKey[pos] = k;
/* 732 */       newValue[pos] = value[i];
/* 733 */       i++;
/*     */     }
/* 735 */     this.n = newN;
/* 736 */     this.mask = newMask;
/* 737 */     this.maxFill = HashCommon.maxFill(this.n, this.f);
/* 738 */     this.key = newKey;
/* 739 */     this.value = newValue;
/* 740 */     this.used = newUsed;
/*     */   }
コード例 #12
0
/*      */   public char get(float k)
/*      */   {
/*  557 */     int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & this.mask;
/*      */ 
/*  559 */     while (this.used[pos] != 0) {
/*  560 */       if (this.key[pos] == k) return this.value[pos];
/*  561 */       pos = pos + 1 & this.mask;
/*      */     }
/*  563 */     return this.defRetValue;
/*      */   }
コード例 #13
0
/*      */   public boolean containsKey(float k)
/*      */   {
/*  568 */     int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & this.mask;
/*      */ 
/*  570 */     while (this.used[pos] != 0) {
/*  571 */       if (this.key[pos] == k) return true;
/*  572 */       pos = pos + 1 & this.mask;
/*      */     }
/*  574 */     return false;
/*      */   }
コード例 #14
0
/*      */   public Character get(Float ok) {
/*  544 */     float k = ok.floatValue();
/*      */ 
/*  546 */     int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & this.mask;
/*      */ 
/*  548 */     while (this.used[pos] != 0) {
/*  549 */       if (this.key[pos] == k) return Character.valueOf(this.value[pos]);
/*  550 */       pos = pos + 1 & this.mask;
/*      */     }
/*  552 */     return null;
/*      */   }
コード例 #15
0
 /**
  * Returns a hash code for this map.
  *
  * <p>This method overrides the generic method provided by the superclass. Since <code>equals()
  * </code> is not overriden, it is important that the value returned by this method is the same
  * value as the one returned by the overriden method.
  *
  * @return a hash code for this map.
  */
 public int hashCode() {
   int h = 0;
   for (int j = size, i = 0, t = 0; j-- != 0; ) {
     while (!used[i]) i++;
     t = it.unimi.dsi.fastutil.HashCommon.long2int(key[i]);
     t ^= it.unimi.dsi.fastutil.HashCommon.float2int(value[i]);
     h += t;
     i++;
   }
   return h;
 }
コード例 #16
0
/*     */   public Long2ByteOpenHashMap(int expected, float f)
/*     */   {
/* 107 */     if ((f <= 0.0F) || (f > 1.0F)) throw new IllegalArgumentException("Load factor must be greater than 0 and smaller than or equal to 1");
/* 108 */     if (expected < 0) throw new IllegalArgumentException("The expected number of elements must be nonnegative");
/* 109 */     this.f = f;
/* 110 */     this.n = HashCommon.arraySize(expected, f);
/* 111 */     this.mask = (this.n - 1);
/* 112 */     this.maxFill = HashCommon.maxFill(this.n, f);
/* 113 */     this.key = new long[this.n];
/* 114 */     this.value = new byte[this.n];
/* 115 */     this.used = new boolean[this.n];
/*     */   }
コード例 #17
0
/*     */   public Object2DoubleOpenCustomHashMap(int expected, float f, Hash.Strategy<K> strategy)
/*     */   {
/* 110 */     this.strategy = strategy;
/* 111 */     if ((f <= 0.0F) || (f > 1.0F)) throw new IllegalArgumentException("Load factor must be greater than 0 and smaller than or equal to 1");
/* 112 */     if (expected < 0) throw new IllegalArgumentException("The expected number of elements must be nonnegative");
/* 113 */     this.f = f;
/* 114 */     this.n = HashCommon.arraySize(expected, f);
/* 115 */     this.mask = (this.n - 1);
/* 116 */     this.maxFill = HashCommon.maxFill(this.n, f);
/* 117 */     this.key = ((Object[])new Object[this.n]);
/* 118 */     this.value = new double[this.n];
/* 119 */     this.used = new boolean[this.n];
/*     */   }
コード例 #18
0
/*      */   public Float2CharLinkedOpenHashMap(int expected, float f)
/*      */   {
/*  151 */     if ((f <= 0.0F) || (f > 1.0F)) throw new IllegalArgumentException("Load factor must be greater than 0 and smaller than or equal to 1");
/*  152 */     if (expected < 0) throw new IllegalArgumentException("The expected number of elements must be nonnegative");
/*  153 */     this.f = f;
/*  154 */     this.n = HashCommon.arraySize(expected, f);
/*  155 */     this.mask = (this.n - 1);
/*  156 */     this.maxFill = HashCommon.maxFill(this.n, f);
/*  157 */     this.key = new float[this.n];
/*  158 */     this.value = new char[this.n];
/*  159 */     this.used = new boolean[this.n];
/*  160 */     this.link = new long[this.n];
/*      */   }
コード例 #19
0
/*      */     public boolean contains(Object o) {
/*  942 */       if (!(o instanceof Map.Entry)) return false;
/*  943 */       Map.Entry e = (Map.Entry)o;
/*  944 */       float k = ((Float)e.getKey()).floatValue();
/*      */ 
/*  946 */       int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & Float2CharLinkedOpenHashMap.this.mask;
/*      */ 
/*  948 */       while (Float2CharLinkedOpenHashMap.this.used[pos] != 0) {
/*  949 */         if (Float2CharLinkedOpenHashMap.this.key[pos] == k) return Float2CharLinkedOpenHashMap.this.value[pos] == ((Character)e.getValue()).charValue();
/*  950 */         pos = pos + 1 & Float2CharLinkedOpenHashMap.this.mask;
/*      */       }
/*  952 */       return false;
/*      */     }
コード例 #20
0
 /**
  * Resizes the map.
  *
  * <p>This method implements the basic rehashing strategy, and may be overriden by subclasses
  * implementing different rehashing strategies (e.g., disk-based rehashing). However, you should
  * not override this method unless you understand the internal workings of this class.
  *
  * @param newN the new size
  */
 @SuppressWarnings("unchecked")
 protected void rehash(final int newN) {
   int i = 0, pos;
   final boolean used[] = this.used;
   double k;
   final double key[] = this.key;
   final double value[] = this.value;
   final int newMask = newN - 1;
   final double newKey[] = new double[newN];
   final double newValue[] = new double[newN];
   final boolean newUsed[] = new boolean[newN];
   for (int j = size; j-- != 0; ) {
     while (!used[i]) i++;
     k = key[i];
     pos = (it.unimi.dsi.fastutil.HashCommon.murmurHash3(strategy.hashCode(k))) & newMask;
     while (newUsed[pos]) pos = (pos + 1) & newMask;
     newUsed[pos] = true;
     newKey[pos] = k;
     newValue[pos] = value[i];
     i++;
   }
   n = newN;
   mask = newMask;
   maxFill = maxFill(n, f);
   this.key = newKey;
   this.value = newValue;
   this.used = newUsed;
 }
コード例 #21
0
 public Float put(final Long ok, final Float ov) {
   final float v = ((ov).floatValue());
   final long k = ((ok).longValue());
   // The starting point.
   int pos = (int) it.unimi.dsi.fastutil.HashCommon.murmurHash3(k) & mask;
   // There's always an unused entry.
   while (used[pos]) {
     if (((key[pos]) == (k))) {
       final Float oldValue = (Float.valueOf(value[pos]));
       value[pos] = v;
       return oldValue;
     }
     pos = (pos + 1) & mask;
   }
   used[pos] = true;
   key[pos] = k;
   value[pos] = v;
   if (size == 0) {
     first = last = pos;
     // Special case of SET_UPPER_LOWER( link[ pos ], -1, -1 );
     link[pos] = -1L;
   } else {
     link[last] ^= ((link[last] ^ (pos & 0xFFFFFFFFL)) & 0xFFFFFFFFL);
     link[pos] = ((last & 0xFFFFFFFFL) << 32) | (-1 & 0xFFFFFFFFL);
     last = pos;
   }
   if (++size >= maxFill) rehash(arraySize(size + 1, f));
   if (ASSERTS) checkTable();
   return (null);
 }
コード例 #22
0
 /**
  * Adds an increment to value currently associated with a key.
  *
  * <p>Note that this method respects the {@linkplain #defaultReturnValue() default return value}
  * semantics: when called with a key that does not currently appears in the map, the key will be
  * associated with the default return value plus the given increment.
  *
  * @param k the key.
  * @param incr the increment.
  * @return the old value, or the {@linkplain #defaultReturnValue() default return value} if no
  *     value was present for the given key.
  */
 public float addTo(final long k, final float incr) {
   // The starting point.
   int pos = (int) it.unimi.dsi.fastutil.HashCommon.murmurHash3(k) & mask;
   // There's always an unused entry.
   while (used[pos]) {
     if (((key[pos]) == (k))) {
       final float oldValue = value[pos];
       value[pos] += incr;
       return oldValue;
     }
     pos = (pos + 1) & mask;
   }
   used[pos] = true;
   key[pos] = k;
   value[pos] = defRetValue + incr;
   if (size == 0) {
     first = last = pos;
     // Special case of SET_UPPER_LOWER( link[ pos ], -1, -1 );
     link[pos] = -1L;
   } else {
     link[last] ^= ((link[last] ^ (pos & 0xFFFFFFFFL)) & 0xFFFFFFFFL);
     link[pos] = ((last & 0xFFFFFFFFL) << 32) | (-1 & 0xFFFFFFFFL);
     last = pos;
   }
   if (++size >= maxFill) rehash(arraySize(size + 1, f));
   if (ASSERTS) checkTable();
   return defRetValue;
 }
コード例 #23
0
/*      */     public boolean remove(Object o) {
/*  956 */       if (!(o instanceof Map.Entry)) return false;
/*  957 */       Map.Entry e = (Map.Entry)o;
/*  958 */       float k = ((Float)e.getKey()).floatValue();
/*      */ 
/*  960 */       int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & Float2CharLinkedOpenHashMap.this.mask;
/*      */ 
/*  962 */       while (Float2CharLinkedOpenHashMap.this.used[pos] != 0) {
/*  963 */         if (Float2CharLinkedOpenHashMap.this.key[pos] == k) {
/*  964 */           Float2CharLinkedOpenHashMap.this.remove(e.getKey());
/*  965 */           return true;
/*      */         }
/*  967 */         pos = pos + 1 & Float2CharLinkedOpenHashMap.this.mask;
/*      */       }
/*  969 */       return false;
/*      */     }
コード例 #24
0
 /**
  * Adds a pair to the map; if the key is already present, it is moved to the last position of the
  * iteration order.
  *
  * @param k the key.
  * @param v the value.
  * @return the old value, or the {@linkplain #defaultReturnValue() default return value} if no
  *     value was present for the given key.
  */
 public float putAndMoveToLast(final long k, final float v) {
   final long key[] = this.key;
   final boolean used[] = this.used;
   final int mask = this.mask;
   // The starting point.
   int pos = (int) it.unimi.dsi.fastutil.HashCommon.murmurHash3(k) & mask;
   // There's always an unused entry.
   while (used[pos]) {
     if (((k) == (key[pos]))) {
       final float oldValue = value[pos];
       value[pos] = v;
       moveIndexToLast(pos);
       return oldValue;
     }
     pos = (pos + 1) & mask;
   }
   used[pos] = true;
   key[pos] = k;
   value[pos] = v;
   if (size == 0) {
     first = last = pos;
     // Special case of SET_UPPER_LOWER( link[ pos ], -1, -1 );
     link[pos] = -1L;
   } else {
     link[last] ^= ((link[last] ^ (pos & 0xFFFFFFFFL)) & 0xFFFFFFFFL);
     link[pos] = ((last & 0xFFFFFFFFL) << 32) | (-1 & 0xFFFFFFFFL);
     last = pos;
   }
   if (++size >= maxFill) rehash(arraySize(size, f));
   if (ASSERTS) checkTable();
   return defRetValue;
 }
コード例 #25
0
 public int nextEntry() {
   if (!hasNext()) throw new NoSuchElementException();
   c--;
   // We are just enumerating elements from the wrapped list.
   if (pos < 0) {
     final Object k = wrapped.get(-(last = --pos) - 2);
     // The starting point.
     int pos =
         (it.unimi.dsi.fastutil.HashCommon.murmurHash3(strategy.hashCode((K) ((K) k)))) & mask;
     // There's always an unused entry.
     while (used[pos]) {
       if ((strategy.equals((key[pos]), (K) ((K) k)))) return pos;
       pos = (pos + 1) & mask;
     }
   }
   last = pos;
   // System.err.println( "Count: " + c );
   if (c != 0) {
     final boolean used[] = Object2CharOpenCustomHashMap.this.used;
     while (pos-- != 0 && !used[pos]) ;
     // When here pos < 0 there are no more elements to be enumerated by scanning, but wrapped
     // might be nonempty.
   }
   return last;
 }
コード例 #26
0
 /**
  * Shifts left entries with the specified hash code, starting at the specified position, and
  * empties the resulting free entry. If any entry wraps around the table, instantiates lazily
  * {@link #wrapped} and stores the entry key.
  *
  * @param pos a starting position.
  * @return the position cleared by the shifting process.
  */
 protected final int shiftKeys(int pos) {
   // Shift entries with the same hash.
   int last, slot;
   for (; ; ) {
     pos = ((last = pos) + 1) & mask;
     while (used[pos]) {
       slot =
           (it.unimi.dsi.fastutil.HashCommon.murmurHash3(strategy.hashCode((K) (key[pos]))))
               & mask;
       if (last <= pos ? last >= slot || slot > pos : last >= slot && slot > pos) break;
       pos = (pos + 1) & mask;
     }
     if (!used[pos]) break;
     if (pos < last) {
       // Wrapped entry.
       if (wrapped == null) wrapped = new ObjectArrayList<K>();
       wrapped.add(key[pos]);
     }
     key[last] = key[pos];
     value[last] = value[pos];
   }
   used[last] = false;
   key[last] = null;
   return last;
 }
コード例 #27
0
/*      */   public char remove(float k)
/*      */   {
/*  319 */     int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & this.mask;
/*      */ 
/*  321 */     while (this.used[pos] != 0) {
/*  322 */       if (this.key[pos] == k) {
/*  323 */         this.size -= 1;
/*  324 */         fixPointers(pos);
/*  325 */         char v = this.value[pos];
/*  326 */         shiftKeys(pos);
/*  327 */         return v;
/*      */       }
/*  329 */       pos = pos + 1 & this.mask;
/*      */     }
/*  331 */     return this.defRetValue;
/*      */   }
コード例 #28
0
/*      */   protected void rehash(int newN)
/*      */   {
/* 1194 */     int i = this.first; int prev = -1; int newPrev = -1;
/*      */ 
/* 1196 */     long[] key = this.key;
/* 1197 */     short[] value = this.value;
/* 1198 */     int newMask = newN - 1;
/* 1199 */     long[] newKey = new long[newN];
/* 1200 */     short[] newValue = new short[newN];
/* 1201 */     boolean[] newUsed = new boolean[newN];
/* 1202 */     long[] link = this.link;
/* 1203 */     long[] newLink = new long[newN];
/* 1204 */     this.first = -1;
/* 1205 */     for (int j = this.size; j-- != 0; ) {
/* 1206 */       long k = key[i];
/* 1207 */       int pos = (int)HashCommon.murmurHash3(k) & newMask;
/* 1208 */       while (newUsed[pos] != 0) pos = pos + 1 & newMask;
/* 1209 */       newUsed[pos] = true;
/* 1210 */       newKey[pos] = k;
/* 1211 */       newValue[pos] = value[i];
/* 1212 */       if (prev != -1) {
/* 1213 */         newLink[newPrev] ^= (newLink[newPrev] ^ pos & 0xFFFFFFFF) & 0xFFFFFFFF;
/* 1214 */         newLink[pos] ^= (newLink[pos] ^ (newPrev & 0xFFFFFFFF) << 32) & 0x0;
/* 1215 */         newPrev = pos;
/*      */       }
/*      */       else {
/* 1218 */         newPrev = this.first = pos;
/*      */ 
/* 1220 */         newLink[pos] = -1L;
/*      */       }
/* 1222 */       int t = i;
/* 1223 */       i = (int)link[i];
/* 1224 */       prev = t;
/*      */     }
/* 1226 */     this.n = newN;
/* 1227 */     this.mask = newMask;
/* 1228 */     this.maxFill = HashCommon.maxFill(this.n, this.f);
/* 1229 */     this.key = newKey;
/* 1230 */     this.value = newValue;
/* 1231 */     this.used = newUsed;
/* 1232 */     this.link = newLink;
/* 1233 */     this.last = newPrev;
/* 1234 */     if (newPrev != -1)
/*      */     {
/* 1236 */       newLink[newPrev] |= 4294967295L;
/*      */     }
/*      */   }
コード例 #29
0
/*      */   protected void rehash(int newN)
/*      */   {
/* 1154 */     int i = this.first; int prev = -1; int newPrev = -1;
/*      */ 
/* 1156 */     float[] key = this.key;
/* 1157 */     char[] value = this.value;
/* 1158 */     int newMask = newN - 1;
/* 1159 */     float[] newKey = new float[newN];
/* 1160 */     char[] newValue = new char[newN];
/* 1161 */     boolean[] newUsed = new boolean[newN];
/* 1162 */     long[] link = this.link;
/* 1163 */     long[] newLink = new long[newN];
/* 1164 */     this.first = -1;
/* 1165 */     for (int j = this.size; j-- != 0; ) {
/* 1166 */       float k = key[i];
/* 1167 */       int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & newMask;
/* 1168 */       while (newUsed[pos] != 0) pos = pos + 1 & newMask;
/* 1169 */       newUsed[pos] = true;
/* 1170 */       newKey[pos] = k;
/* 1171 */       newValue[pos] = value[i];
/* 1172 */       if (prev != -1) {
/* 1173 */         newLink[newPrev] ^= (newLink[newPrev] ^ pos & 0xFFFFFFFF) & 0xFFFFFFFF;
/* 1174 */         newLink[pos] ^= (newLink[pos] ^ (newPrev & 0xFFFFFFFF) << 32) & 0x0;
/* 1175 */         newPrev = pos;
/*      */       }
/*      */       else {
/* 1178 */         newPrev = this.first = pos;
/*      */ 
/* 1180 */         newLink[pos] = -1L;
/*      */       }
/* 1182 */       int t = i;
/* 1183 */       i = (int)link[i];
/* 1184 */       prev = t;
/*      */     }
/* 1186 */     this.n = newN;
/* 1187 */     this.mask = newMask;
/* 1188 */     this.maxFill = HashCommon.maxFill(this.n, this.f);
/* 1189 */     this.key = newKey;
/* 1190 */     this.value = newValue;
/* 1191 */     this.used = newUsed;
/* 1192 */     this.link = newLink;
/* 1193 */     this.last = newPrev;
/* 1194 */     if (newPrev != -1)
/*      */     {
/* 1196 */       newLink[newPrev] |= 4294967295L;
/*      */     }
/*      */   }
コード例 #30
0
/*      */   public char getAndMoveToLast(float k)
/*      */   {
/*  450 */     float[] key = this.key;
/*  451 */     boolean[] used = this.used;
/*  452 */     int mask = this.mask;
/*      */ 
/*  454 */     int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & mask;
/*      */ 
/*  456 */     while (used[pos] != 0) {
/*  457 */       if (k == key[pos]) {
/*  458 */         moveIndexToLast(pos);
/*  459 */         return this.value[pos];
/*      */       }
/*  461 */       pos = pos + 1 & mask;
/*      */     }
/*  463 */     return this.defRetValue;
/*      */   }