A dictionary is a special case of a hash table that stores key-value pairs.
It is an
example of what is called an ``associative container''. In the implementation of FTObjectLibrary,
the value can be any subclass of FTObject and the key is a character variable. The library
includes the base dictionary that can store and retrieve any subclass of FTObject. It also includes a
subclass that is designed to store and retrieve FTValue objects.
FTDictionary (Inherits from FTObject)
Initialization
CLASS(FTDictionary), POINTER :: dict
ALLOCATE(dict)
CALL dict % initWithSize(N) ! N = size of dictionary. Should be power of two
Adding entries
CLASS(FTDictionary), POINTER :: dict
CLASS(FTObject) , POINTER :: obj
CHARACTER(LEN=N) :: key
obj => r ! r is subclass of FTObject
CALL dict % addObjectForKey(obj,key)
Accessing entries
obj => dict % objectForKey(key)
CALL cast(obj,v) ! v is the type of object to be extracted
Destruction
CALL release(dict) ! Pointer
call dict % destruct() ! Stack variable
Accessing an object
TYPE(FTObject) :: obj
obj => dict % objectForKey(key)
Converting a base class pointer to a dictionary
dict => dictionaryFromObject(obj)
Getting all of the keys
CHARACTER(LEN=FTDICT_KWD_STRING_LENGTH), POINTER :: keys(:)
keys => dict % allKeys()
(The target of the pointer must be deallocated by the caller)
Getting all of the objects
CLASS(FTMutableObjectArray), POINTER :: objectArray
objectArray => dict % allObjects() ! The array is owned by the caller.
(The target of the pointer must be released by the caller)
Interfaces
-
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTObject),
|
|
|
POINTER
|
:: |
obj |
|
class(FTDictionary),
|
|
|
POINTER
|
:: |
cast |
|
-
Public, generic name: release(self)
Call release(self) on an object to release control
of an object. If its reference count is zero, then
it is deallocated.
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
type(FTDictionary),
|
|
|
POINTER
|
:: |
self |
|
Derived Types
Components
Type |
Visibility | Attributes |
|
Name |
| Initial | |
integer,
|
public |
|
:: |
numberOfEntries |
|
|
|
logical,
|
public |
|
:: |
isCaseSensitive |
|
|
|
type(FTLinkedList),
|
public, |
DIMENSION(:), POINTER
|
:: |
entries |
=> |
NULL() |
|
Type-Bound Procedures
procedure, public, non_overridable ::
copy => copyFTObject |
|
procedure, public, non_overridable ::
retain => retainFTObject |
|
procedure, public, non_overridable ::
isUnreferenced |
|
procedure, public, non_overridable ::
refCount |
|
procedure, public ::
initWithSize |
|
procedure, public ::
init |
|
procedure, public ::
setCaseSensitive |
|
procedure, public ::
caseSensitive |
|
procedure, public ::
allKeys => AllKeys |
|
procedure, public ::
allObjects => AllObjects |
|
procedure, public ::
destruct => destructFTDictionary |
|
procedure, public ::
addObjectForKey |
|
procedure, public ::
removeObjectForKey |
|
procedure, public ::
description => FTDictionaryDescription |
|
procedure, public ::
printDescription => printFTDictionaryDescription |
|
procedure, public ::
objectForKey |
|
procedure, public ::
containsKey |
|
procedure, public ::
className => dictionaryClassName |
|
procedure, public ::
COUNT |
|
Functions
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
Return Value
logical
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
Return Value
integer
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
character(len=*)
|
|
|
|
:: |
key |
|
Return Value
class(FTObject), POINTER
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
character(len=*)
|
|
|
|
:: |
key |
|
Return Value
logical
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
character(len=*)
|
|
|
|
:: |
key |
|
class(FTLinkedList)
|
|
|
|
:: |
list |
|
Return Value
class(FTObject), POINTER
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
Return Value
character(len=description_character_length)
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
Return Value
character(len=FTDICT_KWD_STRING_LENGTH), POINTER, (:)
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTObject),
|
|
|
POINTER
|
:: |
obj |
|
Return Value
class(FTDictionary), POINTER
Class name returns a string with the name of the type of the object
Read more…
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
Return Value
character(len=CLASS_NAME_CHARACTER_LENGTH)
Subroutines
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
integer,
|
intent(in) |
|
|
:: |
sze |
|
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
Public, generic name: release(self)
Read more…
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
type(FTDictionary),
|
|
|
POINTER
|
:: |
self |
|
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
logical
|
|
|
|
:: |
bool |
|
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
class(FTObject),
|
|
|
POINTER
|
:: |
object |
|
character(len=*)
|
|
|
|
:: |
key |
|
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
character(len=*)
|
|
|
|
:: |
key |
|
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTDictionary)
|
|
|
|
:: |
self |
|
integer
|
|
|
|
:: |
iUnit |
|
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTObject),
|
|
|
POINTER
|
:: |
obj |
|
class(FTDictionary),
|
|
|
POINTER
|
:: |
cast |
|