Ableverse™
Platform 6.0

av.util
Class SoftHashLongMap<T>

java.lang.Object
  extended by av.util.SoftHashLongMap<T>
All Implemented Interfaces:
LongMap<T>, Iterable<T>

public class SoftHashLongMap<T>
extends Object
implements LongMap<T>, Iterable<T>

A simple hash implementation of the LongMap interface.

This map stores values via SoftReference, so won't prevent the objects inside from being garbage collected.

Author:
Compl

Nested Class Summary
static class SoftHashLongMap.Entry<T>
           
protected  class SoftHashLongMap.Itr
           
 
Field Summary
 int slotSize
           
 
Constructor Summary
SoftHashLongMap(int slotSizePower)
          The slot size are regulated from 8 to 4M, with the integral power of 2 specified by slotSizePower.
 
Method Summary
 void clear()
          clear the map
protected  SoftHashLongMap.Entry<T> createEntry(long id, T value)
           
 T get(long id)
           
protected  SoftHashLongMap.Entry<T> getEntry(long id)
           
 int getSlotSize()
           
 Iterator<T> iterator()
           
 void put(long id, T obj)
           
 T remove(long id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

slotSize

public final int slotSize
Constructor Detail

SoftHashLongMap

public SoftHashLongMap(int slotSizePower)
The slot size are regulated from 8 to 4M, with the integral power of 2 specified by slotSizePower.

Parameters:
slotSizePower - Power of 2 used to set the size of the slots, if out of range 3 - 22, adjusted to the nearest number.
Method Detail

createEntry

protected SoftHashLongMap.Entry<T> createEntry(long id,
                                               T value)

getSlotSize

public int getSlotSize()

getEntry

protected SoftHashLongMap.Entry<T> getEntry(long id)

get

public T get(long id)
Specified by:
get in interface LongMap<T>
Returns:
the value at id

remove

public T remove(long id)
Specified by:
remove in interface LongMap<T>
Returns:
the old value at id

put

public void put(long id,
                T obj)
Specified by:
put in interface LongMap<T>

clear

public void clear()
Description copied from interface: LongMap
clear the map

Specified by:
clear in interface LongMap<T>

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>

Ableverse™
Platform 6.0

Copyright© 2006 Ableverse Platform. All rights reserved.