Library | Package Java Toolkit

Class stringdict

package com.ptc.cipjava;

public class stringdict
  implements jxobject



Description

Dictionary of strings.

A dictionary cannot contain duplicate keys, each key can map to at most one value. Dictionary provides methods for accessing a value by its key, for inserting and removing values as well as for iterating through the dictionary elements.



Method Summary
booleancontains (String key)
     
static stringdictcreate ()
    Creates a new empty dictionary.
Stringfind (String key)
    Finds an element with the specified key in the dictionary. If an element is found, returns xtrue and sets the value pointer to point to the found value, otherwise returns xfalse. If the value pointer is 0, this method only verifies if an element with the specified key exists in the dictionary without returning its value.
Stringgetbyindex (int idx)
    Gets the value of an element with the specified index from a dictionary. If an element is found, returns yxtrue and sets the value pointer to point to the found value, otherwise returns xfalse. If the value pointer is 0, this method only verifies if an element with the specified index exists in the dictionary without returning its value. Use this method together with methods getmapsize and getkeybyindex to iterate through the dictionary.
intgetcount ()
     
Stringgetkeybyindex (int idx)
    Gets the key of an element with the specified index from a dictionary. If an element is found, returns xtrue and sets the key pointer to point to the found string value, otherwise returns xfalse. If the key pointer is 0, this method only verifies if an element with the specified index exists in the dictionary without returning its key. Use this method together with methods getmapsize and getbyindex to iterate through the dictionary.
intgetmapsize ()
    Returns the dictionary size. This size can be greater than the current number of elements in the dictionary, in fact this is a size of the dictionary hashtable.
voidremove (String key)
    Removes an element with the specified key from a dictionary.
voidremovebyindex (int idx)
    Removes an element with the specified index from a dictionary. If an element with this index does not exist in the dictionary, throws exception cipXInvalidDictIndex.
voidset (String key, String value)
    Assigns a new value to the dictionary element with the specified key, if such an element exists, otherwise adds a new element with the given key and value to the dictionary.
voidsetbyindex (int idx, String value)
    Changes the value of a dictionary element with the specified index to the specified value. If an element with the specified index does not exist in the dictionary, throws exception cipXInvalidDictIndex.

Method Detail

getmapsize

intgetmapsize ()


    Returns the dictionary size. This size can be greater than the current number of elements in the dictionary, in fact this is a size of the dictionary hashtable.
Returns:
Size of the dictionary.


getcount

intgetcount ()


     
Returns:


contains

booleancontains (String key)


     
Parameters:
key
Returns:


find

Stringfind (String key)


    Finds an element with the specified key in the dictionary. If an element is found, returns xtrue and sets the value pointer to point to the found value, otherwise returns xfalse. If the value pointer is 0, this method only verifies if an element with the specified key exists in the dictionary without returning its value.
Parameters:
key
Key to be found.
Returns:
Specifies if the value is found.


set

voidset (String key, String value)


    Assigns a new value to the dictionary element with the specified key, if such an element exists, otherwise adds a new element with the given key and value to the dictionary.
Parameters:
key
Key of an element.
value
New value of an element.
Returns:


setbyindex

voidsetbyindex (int idx, String value)


    Changes the value of a dictionary element with the specified index to the specified value. If an element with the specified index does not exist in the dictionary, throws exception cipXInvalidDictIndex.
Parameters:
idx
Element index.
value
New element value.
Returns:


remove

voidremove (String key)


    Removes an element with the specified key from a dictionary.
Parameters:
key
Key of an element to remove.
Returns:


removebyindex

voidremovebyindex (int idx)


    Removes an element with the specified index from a dictionary. If an element with this index does not exist in the dictionary, throws exception cipXInvalidDictIndex.
Parameters:
idx
Index of an element to remove.
Returns:


getbyindex

Stringgetbyindex (int idx)


    Gets the value of an element with the specified index from a dictionary. If an element is found, returns yxtrue and sets the value pointer to point to the found value, otherwise returns xfalse. If the value pointer is 0, this method only verifies if an element with the specified index exists in the dictionary without returning its value. Use this method together with methods getmapsize and getkeybyindex to iterate through the dictionary.
Parameters:
idx
Element index.
Returns:
Specifies if the index is found.


getkeybyindex

Stringgetkeybyindex (int idx)


    Gets the key of an element with the specified index from a dictionary. If an element is found, returns xtrue and sets the key pointer to point to the found string value, otherwise returns xfalse. If the key pointer is 0, this method only verifies if an element with the specified index exists in the dictionary without returning its key. Use this method together with methods getmapsize and getbyindex to iterate through the dictionary.
Parameters:
idx
Element index.
Returns:
Specifies if the index is found.


create

static stringdictcreate ()


    Creates a new empty dictionary.
Returns:
Created dictionary.