Question: import java.util.Iterator; public interface DictionaryInterface { /** * An interface for a dictionary with distinct search keys. * * * Note: You must use this

import java.util.Iterator;

public interface DictionaryInterface

{

/**

* An interface for a dictionary with distinct search keys.

*

*

* Note: You must use this interface, without modification, in your Comp 2000,

* Dictionary/Hash Table ADT solution.

*/

/*

* public constants

*/

/** Load factor threshold */

public final static float DEFAULT_LAMBDA_THRESHOLD = 1.0F;

/**

* Force the table size (number of buckets) to a prime number to improve key

* distribution

*/

public final static boolean DEFAULT_FORCE_PRIME_TABLE_SIZE = true;

/** Initial table size (number of buckets) */

public final static int DEFAULT_TABLE_SIZE = 10;

/*

* public methods

*/

/**

* Adds a new entry to this dictionary. If the given search key already exists in the

* dictionary, replaces the corresponding value.

*

* @param key

* An object search key of the new entry.

* @param value

* An object associated with the search key.

* @return Either null if the new entry was added to the dictionary or the value that

* was associated with key if that value was replaced.

*/

public V add(K key, V value);

/**

* Removes all entries from this dictionary.

*/

public void clear();

/**

* Sees whether a specific entry is in this dictionary.

*

* @param key

* An object search key of the desired entry.

* @return True if key is associated with an entry in the dictionary.

*/

public boolean contains(K key);

/**

* Creates an iterator that traverses all search keys in this dictionary.

*

* @return An iterator that provides sequential access to the search keys in the

* dictionary.

*/

public Iterator getKeyIterator();

/**

* Gets the size of this dictionary.

*

* @return The number of entries (key-value pairs) currently in the dictionary.

*/

public int getSize();

/**

* Retrieves from this dictionary the value associated with a given search key.

*

* @param key

* An object search key of the entry to be retrieved.

* @return Either the value that is associated with the search key or null if no such

* object exists.

*/

public V getValue(K key);

/**

* Creates an iterator that traverses all values in this dictionary.

*

* @return An iterator that provides sequential access to the values in this

* dictionary.

*/

public Iterator getValueIterator();

/**

* Sees whether this dictionary is empty.

*

* @return True if the dictionary is empty.

*/

public boolean isEmpty();

/**

* Removes a specific entry from this dictionary.

*

* @param key

* An object search key of the entry to be removed.

* @return Either the value that was associated with the search key or null if no such

* object exists.

*/

public V remove(K key);

/**

* Gets the load factor (lambda) threshold which, when exceeded, causes the hash table

* to be expanded.

*

* @return the current load factor threshold value

*/

public float getLoadFactorThreshold();

/**

* Directs the dictionary to (re-)allocate the hash table array sized to the next

* prime number as necessary.

*

* @return the current flag (true = force resize to increase to next prime number;

* false enables resize to simply double the number of elements in the array

* on resize.

*/

public boolean getPrimeTableSize();

/**

* Sets the load factor (lambda) threshold which, when exceeded, causes the hash table

* to be expanded.

*

* @param newLoadFactor

* a non-negative value

* @return the previous threshold value

*/

public float setLoadFactorThreshold(float newLoadFactor);

/**

* Directs the dictionary to (re-)allocate the hash table array sized to the next

* prime number as necessary.

*

* @param forceToPrime

* if true (default), the next table size will be twice the current size

* increased to the next higher prime number; if false, the next table size

* will simply be twice the current size.

* @return the previous value

*/

public boolean setPrimeTableSize(boolean forceToPrime);

} // end interface DictionaryInterface

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!