jfun.util.dict
Interface Dict

All Superinterfaces:
Map, Sizeable

public interface Dict
extends Map, Sizeable

An immutable associative array. All updates to a Dict should be functional. i.e. They create a new Dict object without changing the state of the existing one.

Author:
Ben Yu Jan 17, 2005

Zephyr Business Solutions Corp.s.


Method Summary
 boolean containsKey(java.lang.Object key)
          Determines if the Dict object contains a value of a certain key.
 Dict copy()
          Create a copy of the Dict object.
 java.util.Map.Entry[] entries()
          Get the entries of the Dict object and store them into the array passed in as argument.
 java.lang.Object get(java.lang.Object key)
          Get the corresponding value of a key.
 boolean isEmpty()
          Tests whether it is empty.
 java.lang.Object[] keys()
          Get the keys of the Dict object in an array.
 java.lang.Object[] keys(java.lang.Object[] buf)
          Get the keys of the Dict object and store them into the array passed in as argument.
 Dict put(java.lang.Object key, java.lang.Object val)
          Functional update.
 Dict puts(java.lang.Object[] keys, java.lang.Object[] vals)
          Functional update.
 Dict remove(java.lang.Object key)
          Functional update.
 Dict removes(java.lang.Object[] keys)
          Functional update.
 int size()
          Get the size.
 java.lang.Object[] values()
          Get the values of the Dict object in an array.
 java.lang.Object[] values(java.lang.Object[] buf)
          Get the values of the Dict object and store them into the array passed in as argument.
 

Method Detail

copy

public Dict copy()
Create a copy of the Dict object. The created Dict object will not share any internal buffer with the existing one.

Returns:
the new Dict object.

containsKey

public boolean containsKey(java.lang.Object key)
Determines if the Dict object contains a value of a certain key.

Parameters:
key - the key to search.
Returns:
true if the key is present in the Dict, false otherwise.

get

public java.lang.Object get(java.lang.Object key)
Description copied from interface: Map
Get the corresponding value of a key.

Specified by:
get in interface Map
Parameters:
key - the key.
Returns:
the value.

isEmpty

public boolean isEmpty()
Description copied from interface: Sizeable
Tests whether it is empty. Some class may provide a more efficient implementation than size().

Specified by:
isEmpty in interface Sizeable
Returns:
true if empty.

keys

public java.lang.Object[] keys()
Get the keys of the Dict object in an array.

Returns:
the array containing all the keys.

values

public java.lang.Object[] values()
Get the values of the Dict object in an array.

Returns:
the array containing all the values.

keys

public java.lang.Object[] keys(java.lang.Object[] buf)
Get the keys of the Dict object and store them into the array passed in as argument.

Returns:
the same array object as the one passed in.

values

public java.lang.Object[] values(java.lang.Object[] buf)
Get the values of the Dict object and store them into the array passed in as argument.

Returns:
the same array object as the one passed in.

entries

public java.util.Map.Entry[] entries()
Get the entries of the Dict object and store them into the array passed in as argument.

Returns:
the same array object as the one passed in.

put

public Dict put(java.lang.Object key,
                java.lang.Object val)
Functional update. Set the value of the given key to the new value.

Parameters:
key - the key.
val - the new value.
Returns:
the new Dict object.

remove

public Dict remove(java.lang.Object key)
Functional update. Remove the entry of the given key.

Parameters:
key - the key.
Returns:
the new Dict object.

puts

public Dict puts(java.lang.Object[] keys,
                 java.lang.Object[] vals)
Functional update. Add key-value pairs and create a new Dict object with these pairs.
the keys and the vals array should have the same length. the keys array should not have duplicates.

Parameters:
keys - the keys.
vals - the values.
Returns:
the new Dict object.

removes

public Dict removes(java.lang.Object[] keys)
Functional update. Remove the entries of the keys. the keys array should not have duplicates.

Parameters:
keys - the keys.
Returns:
the new Dict object.

size

public int size()
Description copied from interface: Sizeable
Get the size.

Specified by:
size in interface Sizeable
Returns:
the size.