close

Hashtable

A collection allows a commission of objects to be processed
as a uninominal component. Map is one of the centre interfaces of java set armature
that defines dealing for maintaining mappings of keys to belief.

Map interface does not instrumentality Collection
interface, because it does not include weather but contains entries of keys and
their similar values (i.e. named mapping).

Map does not let photocopy keys. So location is
utmost one appeal that is mapped beside the specified key. Both key and numerical quantity must be
an Object (Primitive values essential be clothed).

Hashtable implements Map interface (As of the Java 2
platform v1.2, this order has been retrofitted to instrumentality Map, so that it
becomes a cog of Java's assortment theoretical account).

Hashtables will automatically push once you add too
many atmospheric condition. However, mushrooming requires copying, rehashing and rechaining,
which affects its overall deeds.

Performance of Hashtable depends on two of the essence factors that are

Initial Capacity and

Load Factor

Initial Capacity is the dimensions at the time the
hash array is created. Load factor determines once to broaden the dimensions of
the Hashtable. The evasion burden cause is 0.75. Important Note: The pilot
capacity is not the actual figure of weather you proposal to stockpile in hashtable.
Say for example, if you set initial dimensions of 100 and the payload factor is 0.75,
then the size of Hashtable will be insentience enhanced once it reaches
to 75 not 100.

Constructors

Hashtable ()

Constructs useless hashtable beside a non-attendance first capacity
11 and weight factor 0.75.

Hashtable (int initialCapacity)

Constructs hollow hashtable next to the specific initial
capacity and failure to pay oceans cause 0.75.

Hashtable (int initialCapacity, time interval loadFactor)

Constructs isolated hashtable next to the given pilot
capacity and the such as mass factor.

Hashtable (Map t)

Constructs a new hashtable next to the mappings same as the
passed Map.

Basic methods

Object get (Object key)

Returns the value mapped to the nominal key, or null if
no written record is found.

Object put (Object key, Object plus point)

Maps the specified key to the such that plus in this
hashtable and returns the efficacy in the past connected next to the fixed key, if
any. Otherwise, it returns the void efficacy.

Object relocate (Object key)

Removes the key and its related utility from the
hashtable, and returns the expediency in earlier times related to next to the such key,
if any. Otherwise, it returns the void attraction.

boolean containsKey(Object key)

Returns sincere if the nominative key is mapped to whatsoever worth
in the map, other specious.

boolean containsValue(Object significance)

Returns apodeictic if nearby are one or more keys mapped to the
specified value, other phoney.

int size()

Returns the mass
of the hashtable.

boolean isEmpty()

Returns factual if hashtable is empty, other hoax.

Other methods

void putAll(Map t)

copies all mappings from the map
to popular hashtable and replaces ongoing entries, if any.

Void palpable()

Removes all mappings from hashtable.

Collection belief()

Returns collection of the belief restrained in the hashtable.

Enumeration atmospheric condition()

Return Enumeration of the belief contained in the hashtable.

Set entrySet()

Returns a Set of entries restrained in the Hashtable.

Enumeration keys()

Return Enumeration of keys restrained in the hashtable.

Object clone()

Creates replica of the hashtable.

Note: hashtable may
throw IllegalArgumentException, if any unsubstantiated operation is invoked.

arrow
arrow
    全站熱搜

    ppapkpm4 發表在 痞客邦 留言(0) 人氣()