GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
com.jogamp.common.util.WeakIdentityHashMap< K, V > Class Template Reference

Implements a combination of WeakHashMap and IdentityHashMap. More...

Inheritance diagram for com.jogamp.common.util.WeakIdentityHashMap< K, V >:
Collaboration diagram for com.jogamp.common.util.WeakIdentityHashMap< K, V >:

Public Member Functions

 WeakIdentityHashMap ()
 See HashMap#HashMap(). More...
 
 WeakIdentityHashMap (final int initialCapacity, final float loadFactor)
 See HashMap#HashMap(int, float). More...
 
void clear ()
 
boolean containsKey (final Object key)
 
boolean containsValue (final Object value)
 
Set< Map.Entry< K, V > > entrySet ()
 
Set< K > keySet ()
 
boolean equals (final Object o)
 
get (final Object key)
 
put (final K key, final V value)
 
int hashCode ()
 
boolean isEmpty ()
 
void putAll (final Map<? extends K, ? extends V > t)
 
remove (final Object key)
 
int size ()
 
Collection< V > values ()
 

Static Public Member Functions

static WeakIdentityHashMap<?, ?> createWithRequiredSize (final int requiredSize, final float loadFactor)
 Static creation method using capacityForRequiredSize(int, float[]) to instantiate a new WeakIdentityHashMap via WeakIdentityHashMap(int, float). More...
 
static int capacityForRequiredSize (final int requiredSize, final float[] loadFactor)
 Returns the [initial] capacity using the given loadFactor and requiredSize. More...
 

Detailed Description

Implements a combination of WeakHashMap and IdentityHashMap.

Useful for caches that need to key off of a == comparison instead of a .equals.

This class is not a general-purpose Map implementation! While this class implements the Map interface, it intentionally violates Map's general contract, which mandates the use of the equals method when comparing objects. This class is designed for use only in the rare cases wherein reference-equality semantics are required.

Note that this implementation is not synchronized.

Definition at line 75 of file WeakIdentityHashMap.java.

Constructor & Destructor Documentation

◆ WeakIdentityHashMap() [1/2]

See HashMap#HashMap().

Definition at line 82 of file WeakIdentityHashMap.java.

Here is the caller graph for this function:

◆ WeakIdentityHashMap() [2/2]

com.jogamp.common.util.WeakIdentityHashMap< K, V >.WeakIdentityHashMap ( final int  initialCapacity,
final float  loadFactor 
)

See HashMap#HashMap(int, float).

Usable slots before resize are capacity * loadFactor.

Capacity for n-slots w/o resize would be (float)n/loadFactor + 1.0f, see capacityForRequiredSize(int, float[]).

Parameters
initialCapacitydefault value would be 16, i.e. 12 slots @ 0.75f loadFactor before resize
loadFactordefault value would be 0.75f
See also
capacityForRequiredSize(int, float[])
createWithRequiredSize(int, float)

Definition at line 99 of file WeakIdentityHashMap.java.

Member Function Documentation

◆ capacityForRequiredSize()

static int com.jogamp.common.util.WeakIdentityHashMap< K, V >.capacityForRequiredSize ( final int  requiredSize,
final float[]  loadFactor 
)
static

Returns the [initial] capacity using the given loadFactor and requiredSize.

General calculation is (float)requiredSize/loadFactor + 1.0f, using loadFactor := 0.75f.

In case above computed capacity is Bitfield.Util#isPowerOf2(int), the given loadFactor will be increased to avoid next PowerOf2 table size initialization.

Parameters
requiredSizethe user desired n-slots before resize
loadFactorgiven loadFactor, which might be increased a little to avoid next PowerOf2 bloat
Returns
the [initial] capacity to be used for WeakIdentityHashMap(int, float)

Definition at line 132 of file WeakIdentityHashMap.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

Definition at line 151 of file WeakIdentityHashMap.java.

◆ containsKey()

boolean com.jogamp.common.util.WeakIdentityHashMap< K, V >.containsKey ( final Object  key)

Definition at line 158 of file WeakIdentityHashMap.java.

◆ containsValue()

boolean com.jogamp.common.util.WeakIdentityHashMap< K, V >.containsValue ( final Object  value)

Definition at line 164 of file WeakIdentityHashMap.java.

◆ createWithRequiredSize()

static WeakIdentityHashMap<?, ?> com.jogamp.common.util.WeakIdentityHashMap< K, V >.createWithRequiredSize ( final int  requiredSize,
final float  loadFactor 
)
static

Static creation method using capacityForRequiredSize(int, float[]) to instantiate a new WeakIdentityHashMap via WeakIdentityHashMap(int, float).

Parameters
requiredSizethe user desired n-slots before resize
loadFactorgiven loadFactor, which might be increased a little to avoid next PowerOf2 bloat
Returns
the new WeakIdentityHashMap instance

Definition at line 112 of file WeakIdentityHashMap.java.

Here is the call graph for this function:

◆ entrySet()

Set< Map.Entry< K, V > > com.jogamp.common.util.WeakIdentityHashMap< K, V >.entrySet ( )

Definition at line 170 of file WeakIdentityHashMap.java.

◆ equals()

boolean com.jogamp.common.util.WeakIdentityHashMap< K, V >.equals ( final Object  o)

Definition at line 213 of file WeakIdentityHashMap.java.

◆ get()

V com.jogamp.common.util.WeakIdentityHashMap< K, V >.get ( final Object  key)

Definition at line 222 of file WeakIdentityHashMap.java.

◆ hashCode()

Definition at line 234 of file WeakIdentityHashMap.java.

◆ isEmpty()

boolean com.jogamp.common.util.WeakIdentityHashMap< K, V >.isEmpty ( )

Definition at line 240 of file WeakIdentityHashMap.java.

◆ keySet()

Set< K > com.jogamp.common.util.WeakIdentityHashMap< K, V >.keySet ( )

Definition at line 200 of file WeakIdentityHashMap.java.

◆ put()

V com.jogamp.common.util.WeakIdentityHashMap< K, V >.put ( final K  key,
final V  value 
)

Definition at line 228 of file WeakIdentityHashMap.java.

◆ putAll()

void com.jogamp.common.util.WeakIdentityHashMap< K, V >.putAll ( final Map<? extends K, ? extends V >  t)

Definition at line 246 of file WeakIdentityHashMap.java.

Here is the call graph for this function:

◆ remove()

V com.jogamp.common.util.WeakIdentityHashMap< K, V >.remove ( final Object  key)

Definition at line 262 of file WeakIdentityHashMap.java.

◆ size()

Definition at line 268 of file WeakIdentityHashMap.java.

◆ values()

Collection< V > com.jogamp.common.util.WeakIdentityHashMap< K, V >.values ( )

Definition at line 274 of file WeakIdentityHashMap.java.


The documentation for this class was generated from the following file: