jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Public Member Functions | Static Public Attributes | List of all members
org.jau.util.ArrayHashMap< K, V > Class Template Reference

HashMap implementation backed by an ArrayList to preserve order of values. More...

Inheritance diagram for org.jau.util.ArrayHashMap< K, V >:
Collaboration diagram for org.jau.util.ArrayHashMap< K, V >:

Public Member Functions

 ArrayHashMap (final boolean supportNullValue, final int initialCapacity, final float loadFactor)
 
 ArrayHashMap (final ArrayHashMap< K, V > o)
 
final boolean supportsNullValue ()
 Returns true for default behavior, i.e. More...
 
final Object clone ()
 Implementation uses ArrayHashMap(ArrayHashMap). More...
 
final ArrayList< V > getData ()
 Returns this object ordered ArrayList. More...
 
final ArrayList< V > toArrayList ()
 
final HashMap< K, V > getMap ()
 Returns this object hash map. More...
 
final String toString ()
 
final void clear ()
 
Set< K > keySet ()
 
Collection< V > values ()
 
Set< java.util.Map.Entry< K, V > > entrySet ()
 
final V get (final Object key)
 
final V put (final K key, final V value) throws NullPointerException
 
void putAll (final Map<? extends K, ? extends V > m)
 
final V remove (final Object key)
 
final boolean containsKey (final Object key)
 
boolean containsValue (final Object value)
 
final boolean equals (final Object arrayHashMap)
 
final int hashCode ()
 
final boolean isEmpty ()
 
final int size ()
 

Static Public Attributes

static final float DEFAULT_LOAD_FACTOR = 0.75f
 Default load factor: {@value}. More...
 
static final int DEFAULT_INITIAL_CAPACITY = 16
 The default initial capacity: {@value}. More...
 

Detailed Description

HashMap implementation backed by an ArrayList to preserve order of values.

Implementation properties are:

O(1) operations:

O(n) operations:

For thread safety, the application shall decorate access to instances via jau.test.util.parallel.locks.RecursiveLock.

Definition at line 62 of file ArrayHashMap.java.

Constructor & Destructor Documentation

◆ ArrayHashMap() [1/2]

org.jau.util.ArrayHashMap< K, V >.ArrayHashMap ( final boolean  supportNullValue,
final int  initialCapacity,
final float  loadFactor 
)
Parameters
supportNullValueUse true for default behavior, i.e. null can be a valid value. Use false if null is not a valid value, here put(Object, Object) and remove(Object) will be optimized.
initialCapacityuse DEFAULT_INITIAL_CAPACITY for default
loadFactoruse DEFAULT_LOAD_FACTOR for default
See also
supportsNullValue()

Definition at line 87 of file ArrayHashMap.java.

◆ ArrayHashMap() [2/2]

org.jau.util.ArrayHashMap< K, V >.ArrayHashMap ( final ArrayHashMap< K, V >  o)
Returns
a shallow copy of this ArrayHashMap, elements are not copied.

Definition at line 96 of file ArrayHashMap.java.

Member Function Documentation

◆ clear()

final void org.jau.util.ArrayHashMap< K, V >.clear ( )

Definition at line 150 of file ArrayHashMap.java.

◆ clone()

final Object org.jau.util.ArrayHashMap< K, V >.clone ( )

Implementation uses ArrayHashMap(ArrayHashMap).

Returns
a shallow copy of this ArrayHashMap, elements are not copied.

Definition at line 121 of file ArrayHashMap.java.

◆ containsKey()

final boolean org.jau.util.ArrayHashMap< K, V >.containsKey ( final Object  key)

Definition at line 266 of file ArrayHashMap.java.

◆ containsValue()

boolean org.jau.util.ArrayHashMap< K, V >.containsValue ( final Object  value)

Definition at line 271 of file ArrayHashMap.java.

◆ entrySet()

Set< java.util.Map.Entry< K, V > > org.jau.util.ArrayHashMap< K, V >.entrySet ( )

Definition at line 174 of file ArrayHashMap.java.

◆ equals()

final boolean org.jau.util.ArrayHashMap< K, V >.equals ( final Object  arrayHashMap)

Definition at line 276 of file ArrayHashMap.java.

◆ get()

final V org.jau.util.ArrayHashMap< K, V >.get ( final Object  key)

Definition at line 179 of file ArrayHashMap.java.

◆ getData()

final ArrayList< V > org.jau.util.ArrayHashMap< K, V >.getData ( )

Returns this object ordered ArrayList.

Use w/ care, it's not a copy.

See also
toArrayList()

Definition at line 129 of file ArrayHashMap.java.

◆ getMap()

final HashMap< K, V > org.jau.util.ArrayHashMap< K, V >.getMap ( )

Returns this object hash map.

Use w/ care, it's not a copy.

Definition at line 140 of file ArrayHashMap.java.

◆ hashCode()

final int org.jau.util.ArrayHashMap< K, V >.hashCode ( )

Definition at line 284 of file ArrayHashMap.java.

◆ isEmpty()

final boolean org.jau.util.ArrayHashMap< K, V >.isEmpty ( )

Definition at line 289 of file ArrayHashMap.java.

◆ keySet()

Set< K > org.jau.util.ArrayHashMap< K, V >.keySet ( )

Definition at line 156 of file ArrayHashMap.java.

◆ put()

final V org.jau.util.ArrayHashMap< K, V >.put ( final K  key,
final V  value 
) throws NullPointerException

This is an O(1) operation, in case the key does not exist, otherwise O(n).

Exceptions
NullPointerExceptionif value is null but supportsNullValue() == false

Definition at line 192 of file ArrayHashMap.java.

Here is the caller graph for this function:

◆ putAll()

void org.jau.util.ArrayHashMap< K, V >.putAll ( final Map<? extends K, ? extends V >  m)

Definition at line 227 of file ArrayHashMap.java.

Here is the call graph for this function:

◆ remove()

final V org.jau.util.ArrayHashMap< K, V >.remove ( final Object  key)

This is an O(1) operation, in case the key does not exist, otherwise O(n).

Definition at line 242 of file ArrayHashMap.java.

◆ size()

final int org.jau.util.ArrayHashMap< K, V >.size ( )

Definition at line 294 of file ArrayHashMap.java.

◆ supportsNullValue()

final boolean org.jau.util.ArrayHashMap< K, V >.supportsNullValue ( )

Returns true for default behavior, i.e.

null can be a valid value.

Returns false if null is not a valid value, here put(Object, Object) and remove(Object) are optimized operations.

See also
ArrayHashMap(boolean, int, float)

Definition at line 110 of file ArrayHashMap.java.

◆ toArrayList()

final ArrayList< V > org.jau.util.ArrayHashMap< K, V >.toArrayList ( )
Returns
a shallow copy of this ArrayHashMap's ArrayList, elements are not copied.
See also
getData()

Definition at line 135 of file ArrayHashMap.java.

◆ toString()

final String org.jau.util.ArrayHashMap< K, V >.toString ( )

Definition at line 143 of file ArrayHashMap.java.

◆ values()

Collection< V > org.jau.util.ArrayHashMap< K, V >.values ( )

See getData() and toArrayList().

See also
getData()
toArrayList()

Definition at line 169 of file ArrayHashMap.java.

Member Data Documentation

◆ DEFAULT_INITIAL_CAPACITY

final int org.jau.util.ArrayHashMap< K, V >.DEFAULT_INITIAL_CAPACITY = 16
static

The default initial capacity: {@value}.

Definition at line 72 of file ArrayHashMap.java.

◆ DEFAULT_LOAD_FACTOR

final float org.jau.util.ArrayHashMap< K, V >.DEFAULT_LOAD_FACTOR = 0.75f
static

Default load factor: {@value}.

Definition at line 68 of file ArrayHashMap.java.


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