Esempio n. 1
0
  public PersistentMap<Long, V> delete(long key) {
    IntMap<MapEntry<Long, V>> im = getInner(key);
    if (im == null) return this;

    int lo = Bits.lowWord(key);
    if (!im.containsKey(lo)) return this;
    IntMap<MapEntry<Long, V>> newInnerMap = im.delete(lo);
    assert (newInnerMap != im);
    IntMap<IntMap<MapEntry<Long, V>>> newData = data.include(Bits.highWord(key), newInnerMap);
    return new LongMap<V>(newData, count - 1);
  }
Esempio n. 2
0
 @Override
 public boolean containsKey(Object key) {
   long k = toKey(key);
   IntMap<MapEntry<Long, V>> im = getInner(k);
   if (im == null) return false;
   return im.containsKey(Bits.lowWord(k));
 }
Esempio n. 3
0
 public V get(long key) {
   IntMap<MapEntry<Long, V>> im = getInner(key);
   if (im == null) return null;
   MapEntry<Long, V> entry = im.get(Bits.lowWord(key));
   if (entry == null) return null;
   return entry.getValue();
 }
Esempio n. 4
0
 @Override
 public java.util.Map.Entry<Long, V> getMapEntry(Object key) {
   long k = toKey(key);
   IntMap<MapEntry<Long, V>> im = getInner(k);
   if (im == null) return null;
   MapEntry<Long, V> entry = im.get(Bits.lowWord(k));
   if (entry == null) return null;
   return entry;
 }
Esempio n. 5
0
  @Override
  public PersistentMap<Long, V> include(Long key, V value) {
    IntMap<MapEntry<Long, V>> im = getInner(key);
    MapEntry<Long, V> entry = new MapEntry<Long, V>(key, value);
    long newCount = count;
    int lo = Bits.lowWord(key);
    if (im == null) {
      im = IntMap.create(lo, entry);
      newCount += 1;
    } else {
      if (!im.containsKey(lo)) newCount++;
      im = im.include(lo, entry);
    }

    IntMap<IntMap<MapEntry<Long, V>>> newData = data.include(Bits.highWord(key), im);
    if (data == newData) return this;
    return new LongMap<V>(newData, newCount);
  }
Esempio n. 6
0
 @Override
 public V get(Object key) {
   long k = toKey(key);
   IntMap<MapEntry<Long, V>> im = getInner(k);
   if (im == null) return null;
   MapEntry<Long, V> entry = im.get(Bits.lowWord(k));
   if (entry == null) return null;
   return entry.getValue();
 }
Esempio n. 7
0
 private IntMap<MapEntry<Long, V>> getInner(long key) {
   return data.get(Bits.highWord(key));
 }