Ableverse™
Platform 6.0

av.util
Class WeakHashLongMap<T>

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

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

A simple hash implementation of the LongMap interface.

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

Author:
Compl

Nested Class Summary
static class WeakHashLongMap.Entry<T>
           
protected  class WeakHashLongMap.Itr
           
 
Field Summary
 int slotSize
           
 
Constructor Summary
WeakHashLongMap(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  WeakHashLongMap.Entry<T> createEntry(long id, T value)
           
 T get(long id)
           
protected  WeakHashLongMap.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

WeakHashLongMap

public WeakHashLongMap(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 WeakHashLongMap.Entry<T> createEntry(long id,
                                               T value)

getSlotSize

public int getSlotSize()

getEntry

protected WeakHashLongMap.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.