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

Hashed ArrayList implementation of the List and Collection interface. More...

Inheritance diagram for org.jau.util.ArrayHashSet< E >:
Collaboration diagram for org.jau.util.ArrayHashSet< E >:

Public Member Functions

 ArrayHashSet (final boolean supportNullValue, final int initialCapacity, final float loadFactor)
 
 ArrayHashSet (final ArrayHashSet< E > o)
 
final boolean supportsNullValue ()
 Returns true for default behavior, i.e. More...
 
final Object clone ()
 
final ArrayList< E > getData ()
 Returns this object ordered ArrayList. More...
 
final HashMap< E, E > getMap ()
 Returns this object hash map. More...
 
final String toString ()
 
final void clear ()
 
final boolean add (final E element) throws NullPointerException
 Add element at the end of this list, if it is not contained yet. More...
 
final boolean remove (final Object element) throws NullPointerException
 Remove element from this list. More...
 
final boolean addAll (final Collection<? extends E > c)
 Add all elements of given java.util.Collection at the end of this list. More...
 
final boolean contains (final Object element)
 Test for containment
This is an O(1) operation. More...
 
final boolean containsAll (final Collection<?> c)
 Test for containment of given java.util.Collection
This is an O(n) operation, over the given Collection size. More...
 
final boolean removeAll (final Collection<?> c)
 Remove all elements of given java.util.Collection from this list. More...
 
final boolean retainAll (final Collection<?> c)
 Retain all elements of the given java.util.Collection c, ie remove all elements not contained by the given java.util.Collection c. More...
 
final boolean equals (final Object arrayHashSet)
 This is an O(n) operation. More...
 
final int hashCode ()
 This is an O(n) operation over the size of this list. More...
 
final boolean isEmpty ()
 
final Iterator< E > iterator ()
 
final int size ()
 
final Object[] toArray ()
 
final< T > T[] toArray (final T[] a)
 
final E get (final int index)
 
final int indexOf (final Object element)
 
final void add (final int index, final E element) throws IllegalArgumentException, NullPointerException
 Add element at the given index in this list, if it is not contained yet. More...
 
final boolean addAll (final int index, final Collection<? extends E > c) throws UnsupportedOperationException
 
final E set (final int index, final E element)
 
final E remove (final int index)
 Remove element at given index from this list. More...
 
final int lastIndexOf (final Object o)
 Since this list is unique, equivalent to indexOf(java.lang.Object). More...
 
final ListIterator< E > listIterator ()
 
final ListIterator< E > listIterator (final int index)
 
final List< E > subList (final int fromIndex, final int toIndex)
 
final ArrayList< E > toArrayList ()
 
final E get (final Object element)
 Identity method allowing to get the identical object, using the internal hash map. More...
 
final E getOrAdd (final E element) throws NullPointerException
 Identity method allowing to get the identical object, using the internal hash map. More...
 
final boolean containsSafe (final Object element)
 Test for containment
This is an O(n) operation, using equals operation over the list. More...
 

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

Hashed ArrayList implementation of the List and Collection interface.

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 66 of file ArrayHashSet.java.

Constructor & Destructor Documentation

◆ ArrayHashSet() [1/2]

org.jau.util.ArrayHashSet< E >.ArrayHashSet ( 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 remove(E) and getOrAdd(Object) will be optimized.
initialCapacityuse DEFAULT_INITIAL_CAPACITY for default
loadFactoruse DEFAULT_LOAD_FACTOR for default
See also
supportsNullValue()

Definition at line 91 of file ArrayHashSet.java.

◆ ArrayHashSet() [2/2]

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

Definition at line 100 of file ArrayHashSet.java.

Member Function Documentation

◆ add() [1/2]

final boolean org.jau.util.ArrayHashSet< E >.add ( final E  element) throws NullPointerException

Add element at the end of this list, if it is not contained yet.


This is an O(1) operation

Returns
true if the element was added to this list, otherwise false (already contained).
Exceptions
NullPointerExceptionif element is null but supportsNullValue() == false

Definition at line 159 of file ArrayHashSet.java.

Here is the caller graph for this function:

◆ add() [2/2]

final void org.jau.util.ArrayHashSet< E >.add ( final int  index,
final E  element 
) throws IllegalArgumentException, NullPointerException

Add element at the given index in this list, if it is not contained yet.


This is an O(1) operation

Exceptions
IllegalArgumentExceptionif the given element was already contained
NullPointerExceptionif element is null but supportsNullValue() == false

Definition at line 396 of file ArrayHashSet.java.

◆ addAll() [1/2]

final boolean org.jau.util.ArrayHashSet< E >.addAll ( final Collection<? extends E >  c)

Add all elements of given java.util.Collection at the end of this list.


This is an O(n) operation, over the given Collection size.

Returns
true if at least one element was added to this list, otherwise false (completely container).

Definition at line 226 of file ArrayHashSet.java.

Here is the call graph for this function:

◆ addAll() [2/2]

final boolean org.jau.util.ArrayHashSet< E >.addAll ( final int  index,
final Collection<? extends E >  c 
) throws UnsupportedOperationException
Exceptions
UnsupportedOperationException

Definition at line 418 of file ArrayHashSet.java.

◆ clear()

final void org.jau.util.ArrayHashSet< E >.clear ( )

Definition at line 141 of file ArrayHashSet.java.

◆ clone()

final Object org.jau.util.ArrayHashSet< E >.clone ( )
Returns
a shallow copy of this ArrayHashSet, elements are not copied.

Definition at line 124 of file ArrayHashSet.java.

◆ contains()

final boolean org.jau.util.ArrayHashSet< E >.contains ( final Object  element)

Test for containment
This is an O(1) operation.

Returns
true if the given element is contained by this list using fast hash map, otherwise false.

Definition at line 246 of file ArrayHashSet.java.

Here is the caller graph for this function:

◆ containsAll()

final boolean org.jau.util.ArrayHashSet< E >.containsAll ( final Collection<?>  c)

Test for containment of given java.util.Collection
This is an O(n) operation, over the given Collection size.

Returns
true if the given Collection is completly contained by this list using hash map, otherwise false.

Definition at line 262 of file ArrayHashSet.java.

Here is the call graph for this function:

◆ containsSafe()

final boolean org.jau.util.ArrayHashSet< E >.containsSafe ( final Object  element)

Test for containment
This is an O(n) operation, using equals operation over the list.


You may utilize this method to verify your hash values,
ie contains(java.lang.Object) and containsSafe(java.lang.Object) shall have the same result.

Returns
true if the given element is contained by this list using slow equals operation, otherwise false.

Definition at line 553 of file ArrayHashSet.java.

◆ equals()

final boolean org.jau.util.ArrayHashSet< E >.equals ( final Object  arrayHashSet)

This is an O(n) operation.

Returns
true if arrayHashSet is of type ArrayHashSet and all entries are equal Performance: arrayHashSet(1)

Definition at line 324 of file ArrayHashSet.java.

◆ get() [1/2]

final E org.jau.util.ArrayHashSet< E >.get ( final int  index)

Definition at line 375 of file ArrayHashSet.java.

◆ get() [2/2]

final E org.jau.util.ArrayHashSet< E >.get ( final Object  element)

Identity method allowing to get the identical object, using the internal hash map.


This is an O(1) operation.

Parameters
elementhash source to find the identical Object within this list
Returns
object from this list, identical to the given key hash code, or null if not contained

Definition at line 505 of file ArrayHashSet.java.

◆ getData()

final ArrayList< E > org.jau.util.ArrayHashSet< E >.getData ( )

Returns this object ordered ArrayList.

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

Definition at line 129 of file ArrayHashSet.java.

◆ getMap()

final HashMap< E, E > org.jau.util.ArrayHashSet< E >.getMap ( )

Returns this object hash map.

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

Definition at line 131 of file ArrayHashSet.java.

◆ getOrAdd()

final E org.jau.util.ArrayHashSet< E >.getOrAdd ( final E  element) throws NullPointerException

Identity method allowing to get the identical object, using the internal hash map.


If the element is not yet contained, add it.
This is an O(1) operation.

Parameters
elementhash source to find the identical Object within this list
Returns
object from this list, identical to the given key hash code, or add the given key and return it.
Exceptions
NullPointerExceptionif element is null but supportsNullValue() == false

Definition at line 520 of file ArrayHashSet.java.

Here is the call graph for this function:

◆ hashCode()

final int org.jau.util.ArrayHashSet< E >.hashCode ( )

This is an O(n) operation over the size of this list.

Returns
the hash code of this list as define in java.util.List#hashCode(), ie hashing all elements of this list.

Definition at line 341 of file ArrayHashSet.java.

◆ indexOf()

final int org.jau.util.ArrayHashSet< E >.indexOf ( final Object  element)

Definition at line 380 of file ArrayHashSet.java.

Here is the caller graph for this function:

◆ isEmpty()

final boolean org.jau.util.ArrayHashSet< E >.isEmpty ( )

Definition at line 346 of file ArrayHashSet.java.

◆ iterator()

final Iterator< E > org.jau.util.ArrayHashSet< E >.iterator ( )

Definition at line 351 of file ArrayHashSet.java.

◆ lastIndexOf()

final int org.jau.util.ArrayHashSet< E >.lastIndexOf ( final Object  o)

Since this list is unique, equivalent to indexOf(java.lang.Object).


This is an O(n) operation.

Returns
index of element, or -1 if not found

Definition at line 466 of file ArrayHashSet.java.

Here is the call graph for this function:

◆ listIterator() [1/2]

final ListIterator< E > org.jau.util.ArrayHashSet< E >.listIterator ( )

Definition at line 471 of file ArrayHashSet.java.

◆ listIterator() [2/2]

final ListIterator< E > org.jau.util.ArrayHashSet< E >.listIterator ( final int  index)

Definition at line 476 of file ArrayHashSet.java.

◆ remove() [1/2]

final E org.jau.util.ArrayHashSet< E >.remove ( final int  index)

Remove element at given index from this list.


This is an O(n) operation.

Returns
the removed object

Definition at line 447 of file ArrayHashSet.java.

◆ remove() [2/2]

final boolean org.jau.util.ArrayHashSet< E >.remove ( final Object  element) throws NullPointerException

Remove element from this list.


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

Returns
true if the element was removed from this list, otherwise false (not contained).
Exceptions
NullPointerExceptionif element is null but supportsNullValue() == false

Definition at line 191 of file ArrayHashSet.java.

◆ removeAll()

final boolean org.jau.util.ArrayHashSet< E >.removeAll ( final Collection<?>  c)

Remove all elements of given java.util.Collection from this list.


This is an O(n) operation.

Returns
true if at least one element of this list was removed, otherwise false.

Definition at line 283 of file ArrayHashSet.java.

◆ retainAll()

final boolean org.jau.util.ArrayHashSet< E >.retainAll ( final Collection<?>  c)

Retain all elements of the given java.util.Collection c, ie remove all elements not contained by the given java.util.Collection c.


This is an O(n) operation.

Returns
true if at least one element of this list was removed, otherwise false.

Definition at line 304 of file ArrayHashSet.java.

◆ set()

final E org.jau.util.ArrayHashSet< E >.set ( final int  index,
final E  element 
)

Definition at line 428 of file ArrayHashSet.java.

Here is the call graph for this function:

◆ size()

final int org.jau.util.ArrayHashSet< E >.size ( )

Definition at line 356 of file ArrayHashSet.java.

◆ subList()

final List< E > org.jau.util.ArrayHashSet< E >.subList ( final int  fromIndex,
final int  toIndex 
)

Definition at line 481 of file ArrayHashSet.java.

◆ supportsNullValue()

final boolean org.jau.util.ArrayHashSet< E >.supportsNullValue ( )

Returns true for default behavior, i.e.

null can be a valid value.

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

See also
ArrayHashSet(boolean, int, float)

Definition at line 114 of file ArrayHashSet.java.

◆ toArray() [1/2]

final Object[] org.jau.util.ArrayHashSet< E >.toArray ( )

Definition at line 361 of file ArrayHashSet.java.

◆ toArray() [2/2]

final< T > T[] org.jau.util.ArrayHashSet< E >.toArray ( final T[]  a)

Definition at line 366 of file ArrayHashSet.java.

◆ toArrayList()

final ArrayList< E > org.jau.util.ArrayHashSet< E >.toArrayList ( )
Returns
a shallow copy of this ArrayHashSet's ArrayList, elements are not copied.

Definition at line 492 of file ArrayHashSet.java.

◆ toString()

final String org.jau.util.ArrayHashSet< E >.toString ( )

Definition at line 134 of file ArrayHashSet.java.

Member Data Documentation

◆ DEFAULT_INITIAL_CAPACITY

final int org.jau.util.ArrayHashSet< E >.DEFAULT_INITIAL_CAPACITY = 16
static

The default initial capacity: {@value}.

Definition at line 76 of file ArrayHashSet.java.

◆ DEFAULT_LOAD_FACTOR

final float org.jau.util.ArrayHashSet< E >.DEFAULT_LOAD_FACTOR = 0.75f
static

Default load factor: {@value}.

Definition at line 72 of file ArrayHashSet.java.


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