Exemplo 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);
  }
Exemplo 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));
 }
Exemplo 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();
 }
Exemplo 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;
 }
Exemplo 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);
  }
Exemplo 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();
 }
Exemplo n.º 7
0
 private IntMap<MapEntry<Long, V>> getInner(long key) {
   return data.get(Bits.highWord(key));
 }