Class Dictionary
java.lang.Object
src.Dictionary
- All Implemented Interfaces:
Cloneable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value for the key.voidclear()Clears the dictionary.clone()Returns a shallow copy of the dictionary.copy()Returns a shallow copy of the dictionary.voidRemoves the key, value pair from the dictionary.booleanChecks if two dictionaries are equal (deep).static DictionaryReturns a new dictionary with keys from array and values set to None.static DictionaryReturns a new dictionary with keys from array and values set to defaultValue.Returns the value for the key.Returns the value for the key, or defaultValue if not found.booleanReturns if the key exists in the dictionary.inthashCode()Returns the hash code of the dictionary.items()Returns an array of key, value pairs.keys()Returns an array of the keys from the dictionary.intlength()Returns the number of items in the dictionary.Object[]list()Returns an array with the dictionary keys.merge(Dictionary dict) Returns a new dictionary with the keys and values of the other two.Removes the key, value pair and returns the value with the key.Removes the key, value pair and return the value with the key, if not found returns defaultValue.Object[]popItem()Removes the last key, value pair and return the pair.voidAdd a key, value pair to the dictionary.Object[]reversed()Returns an array with the dictionary keys in reversed order of insertion.setDefault(Object key) Return the value of the key, if it does not exist the key is inserted.setDefault(Object key, Object value) Return the value of the key, if it does not exist the key is inserted.toString()Returns a string representation of the dictionary.voidUpdates the values of the keys in the given key, value array and if does not exists, insert them.voidupdate(Dictionary dict) Updates the values of the keys in the given dictionary and if does not exist, insert them.values()Returns an array of the values from the dictionary.
-
Constructor Details
-
Dictionary
public Dictionary() -
Dictionary
-
Dictionary
-
-
Method Details
-
clear
public void clear()Clears the dictionary. -
copy
Returns a shallow copy of the dictionary.- Returns:
- Copy of dictionary
- Throws:
CloneNotSupportedException- if the dictionary cannot be cloned
-
clone
Returns a shallow copy of the dictionary.- Overrides:
clonein classObject- Returns:
- Cloned dictionary
- Throws:
CloneNotSupportedException
-
fromKeys
Returns a new dictionary with keys from array and values set to None.- Parameters:
keys- Array of keys- Returns:
- Dictionary with keys
-
fromKeys
Returns a new dictionary with keys from array and values set to defaultValue.- Parameters:
keys- Array of keysdefaultValue- Default value for keys- Returns:
- Dictionary with keys
-
get
Returns the value for the key.- Parameters:
key- Key to search- Returns:
- Value for the key, null if not found
- Throws:
NonHashableKey
-
access
-
get
-
items
Returns an array of key, value pairs.- Returns:
- an DictItems object with the dictionary's (key, value) pairs.
-
keys
Returns an array of the keys from the dictionary.- Returns:
- a DictKeys object with the dictionary's keys.
-
values
Returns an array of the values from the dictionary.- Returns:
- an array of values.
-
list
-
reversed
Returns an array with the dictionary keys in reversed order of insertion.- Returns:
- an array with the keys.
-
pop
-
pop
-
popItem
-
setDefault
-
setDefault
-
put
Add a key, value pair to the dictionary.- Parameters:
key- a key to add.value- a value for the key.- Throws:
NonHashableKey
-
update
Updates the values of the keys in the given dictionary and if does not exist, insert them.- Parameters:
dict- a dictionary to merge.
-
update
Updates the values of the keys in the given key, value array and if does not exists, insert them.- Parameters:
array- an array to merge
-
has
Returns if the key exists in the dictionary.- Parameters:
key- a key to search.- Returns:
- whether the key exist in the dictionary.
-
delete
-
merge
Returns a new dictionary with the keys and values of the other two.- Parameters:
dict- a dictionary to merge.- Returns:
- a new dictionary with the keys and values of the other two.
-
toString
-
equals
-
hashCode
-
length
public int length()Returns the number of items in the dictionary.- Returns:
- nItems in the dictionary.
-