FTDictionaryClass Module

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 releaseFTDictionary(dict) [Pointer]

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)


Uses

  • module~~ftdictionaryclass~~UsesGraph module~ftdictionaryclass FTDictionaryClass module~ftkeyobjectpairclass FTKeyObjectPairClass module~ftdictionaryclass->module~ftkeyobjectpairclass module~ftlinkedlistclass FTLinkedListClass module~ftdictionaryclass->module~ftlinkedlistclass module~ftlinkedlistiteratorclass FTLinkedListIteratorClass module~ftdictionaryclass->module~ftlinkedlistiteratorclass module~ftmutableobjectarrayclass FTMutableObjectArrayClass module~ftdictionaryclass->module~ftmutableobjectarrayclass module~hashmodule HashModule module~ftdictionaryclass->module~hashmodule module~ftobjectclass FTObjectClass module~ftkeyobjectpairclass->module~ftobjectclass module~ftlinkedlistclass->module~ftmutableobjectarrayclass module~ftlinkedlistrecordclass FTLinkedListRecordClass module~ftlinkedlistclass->module~ftlinkedlistrecordclass module~ftlinkedlistiteratorclass->module~ftlinkedlistclass module~ftmutableobjectarrayclass->module~ftobjectclass module~ftlinkedlistrecordclass->module~ftobjectclass

Used by

  • module~~ftdictionaryclass~~UsedByGraph module~ftdictionaryclass FTDictionaryClass module~ftexceptionclass FTExceptionClass module~ftexceptionclass->module~ftdictionaryclass module~ftvaluedictionaryclass FTValueDictionaryClass module~ftexceptionclass->module~ftvaluedictionaryclass module~ftobjectlibrary FTObjectLibrary module~ftobjectlibrary->module~ftdictionaryclass module~ftobjectlibrary->module~ftexceptionclass module~ftobjectlibrary->module~ftvaluedictionaryclass module~ftstringsetclass FTStringSetClass module~ftstringsetclass->module~ftdictionaryclass module~ftvaluedictionaryclass->module~ftdictionaryclass module~sharedexceptionmanagermodule SharedExceptionManagerModule module~sharedexceptionmanagermodule->module~ftexceptionclass

Interfaces

public interface cast


Derived Types

type, public, extends(FTObject) ::  FTDictionary

Components

Type Visibility Attributes Name Initial
integer, public :: numberOfEntries
logical, public :: isCaseSensitive
type(FTLinkedList), public, DIMENSION(:), POINTER :: entries => NULL()

Finalizations Procedures

final :: destructFTDictionary

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 :: allKeys => AllKeys
procedure, public :: allObjects => AllObjects
procedure, public :: addObjectForKey
procedure, public :: description => FTDictionaryDescription
procedure, public :: printDescription => printFTDictionaryDescription
procedure, public :: objectForKey
procedure, public :: containsKey
procedure, public :: className => dictionaryClassName
procedure, public :: COUNT

Functions

public function COUNT(self)

Arguments

Type IntentOptional Attributes Name
class(FTDictionary) :: self

Return Value integer

public function objectForKey(self, key)

Arguments

Type IntentOptional Attributes Name
class(FTDictionary) :: self
character(len=*) :: key

Return Value class(FTObject), POINTER

public function containsKey(self, key) result(r)

Arguments

Type IntentOptional Attributes Name
class(FTDictionary) :: self
character(len=*) :: key

Return Value logical

public function FTDictionaryDescription(self)

Arguments

Type IntentOptional Attributes Name
class(FTDictionary) :: self

Return Value character(len=description_character_length)

public function AllObjects(self) result(objectArray)

Arguments

Type IntentOptional Attributes Name
class(FTDictionary) :: self

Return Value class(FTMutableObjectArray), POINTER

public function AllKeys(self) result(keys)

Arguments

Type IntentOptional Attributes Name
class(FTDictionary) :: self

Return Value character(len=FTDICT_KWD_STRING_LENGTH), POINTER, (:)

public function dictionaryFromObject(obj) result(cast)

Arguments

Type IntentOptional Attributes Name
class(FTObject), POINTER :: obj

Return Value class(FTDictionary), POINTER

public function dictionaryClassName(self) result(s)

Class name returns a string with the name of the type of the object

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTDictionary) :: self

Return Value character(len=CLASS_NAME_CHARACTER_LENGTH)


Subroutines

public subroutine init(self)

Arguments

Type IntentOptional Attributes Name
class(FTDictionary) :: self

public subroutine initWithSize(self, sze)

Arguments

Type IntentOptional Attributes Name
class(FTDictionary) :: self
integer, intent(in) :: sze

public subroutine releaseFTDictionary(self)

Arguments

Type IntentOptional Attributes Name
type(FTDictionary), POINTER :: self

public subroutine destructFTDictionary(self)

Arguments

Type IntentOptional Attributes Name
type(FTDictionary) :: self

public subroutine addObjectForKey(self, object, key)

Arguments

Type IntentOptional Attributes Name
class(FTDictionary) :: self
class(FTObject), POINTER :: object
character(len=*) :: key

public recursive subroutine printFTDictionaryDescription(self, iUnit)

Arguments

Type IntentOptional Attributes Name
class(FTDictionary) :: self
integer :: iUnit

public subroutine castToDictionary(obj, cast)

Arguments

Type IntentOptional Attributes Name
class(FTObject), POINTER :: obj
class(FTDictionary), POINTER :: cast