FTLinkedListClass Module

FTLinkedList is a container class that stores objects in a linked list.

Inherits from FTObjectClass

Definition (Subclass of FTObject):

     TYPE(FTLinkedList) :: list

Usage:

Initialization

     CLASS(FTLinkedList), POINTER :: list
     ALLOCATE(list)
     CALL list % init

Adding objects

     CLASS(FTLinkedList), POINTER :: list, listToAdd
     CLASS(FTObject)    , POINTER :: objectPtr

     objectPtr => r                ! r is subclass of FTObject
     CALL list % Add(objectPtr)    ! Pointer is retained by list
     CALL release(r)               ! If caller relinquishes ownership

     CALL list % addObjectsFromList(listToAdd)

Inserting objects

     CLASS(FTLinkedList)      , POINTER :: list
     CLASS(FTObject)          , POINTER :: objectPtr, obj
     CLASS(FTLinkedListRecord), POINTER :: record

     objectPtr => r                                        ! r is subclass of FTObject
     CALL list % insertObjectAfterRecord(objectPtr,record) ! Pointer is retained by list
     CALL release(r)                                       ! If caller reliquishes ownership

     objectPtr => r                                     ! r is subclass of FTObject
     CALL list % insertObjectAfterObject(objectPtr,obj) ! Pointer is retained by list
     CALL release(r)                                    ! If caller reliquishes ownership

Removing objects

     CLASS(FTLinkedList), POINTER :: list
     CLASS(FTObject)    , POINTER :: objectPtr
     objectPtr => r                 ! r is subclass of FTObject
     CALL list % remove(objectPtr)

Getting all objects as an object array

     CLASS(FTLinkedList)        , POINTER :: list
     CLASS(FTMutableObjectArray), POINTER :: array
     array => list % allObjects() ! Array has refCount = 1

Counting the number of objects in the list

     n = list % count()

Destruction

     CALL release(list) [Pointers]
     CALL list % destruct() [Non Pointers]

!



Interfaces

public interface cast

public interface release

  • public subroutine releaseFTLinkedList(self)

    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 IntentOptional Attributes Name
    type(FTLinkedList), POINTER :: self

Derived Types

type, public, extends(FTObject) ::  FTLinkedList

Components

Type Visibility Attributes Name Initial
class(FTLinkedListRecord), public, POINTER :: head => NULL()
class(FTLinkedListRecord), public, POINTER :: tail => NULL()
integer, public :: nRecords
logical, public :: isCircular_

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 :: init => initFTLinkedList
procedure, public :: add
procedure, public :: remove => removeObject
procedure, public :: reverse => reverseLinkedList
procedure, public :: removeRecord => removeLinkedListRecord
procedure, public :: destruct => destructFTLinkedList
procedure, public :: count => numberOfRecords
procedure, public :: description => FTLinkedListDescription
procedure, public :: printDescription => printFTLinkedListDescription
procedure, public :: className => linkedListClassName
procedure, public :: allObjects => allLinkedListObjects
procedure, public :: removeAllObjects => removeAllLinkedListObjects
procedure, public :: addObjectsFromList
procedure, public :: makeCircular
procedure, public :: isCircular
procedure, public :: insertObjectAfterRecord
procedure, public :: insertObjectAfterObject

Functions

public function isCircular(self)

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self

Return Value logical

public function numberOfRecords(self)

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self

Return Value integer

public function FTLinkedListDescription(self)

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self

Return Value character(len=DESCRIPTION_CHARACTER_LENGTH)

public function allLinkedListObjects(self) result(array)

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self

Return Value class(FTMutableObjectArray), POINTER

public function linkedListClassName(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(FTLinkedList) :: self

Return Value character(len=CLASS_NAME_CHARACTER_LENGTH)

public function linkedListFromObject(obj) result(cast)

Arguments

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

Return Value class(FTLinkedList), POINTER


Subroutines

public subroutine initFTLinkedList(self)

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self

public subroutine add(self, obj)

Arguments

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

public subroutine addObjectsFromList(self, list)

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self
class(FTLinkedList), POINTER :: list

public subroutine insertObjectAfterRecord(self, obj, after)

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self
class(FTObject), POINTER :: obj
class(FTLinkedListRecord), POINTER :: after

public subroutine insertObjectAfterObject(self, obj, after)

Arguments

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

public subroutine makeCircular(self, circular)

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self
logical :: circular

public subroutine removeObject1(self, obj)

Arguments

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

public subroutine removeObject(self, obj)

Arguments

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

public subroutine removeLinkedListRecord(self, listRecord)

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self
class(FTLinkedListRecord), POINTER :: listRecord

public subroutine removeAllLinkedListObjects(self)

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self

public subroutine destructFTLinkedList(self)

The destructor must only be called from within the destructors of subclasses It is automatically called by release().

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self

public subroutine releaseFTLinkedList(self)

Public, generic name: release(self)

Read more…

Arguments

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

public subroutine printFTLinkedListDescription(self, iUnit)

Arguments

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

public subroutine reverseLinkedList(self)

Arguments

Type IntentOptional Attributes Name
class(FTLinkedList) :: self

public subroutine castObjectToLinkedList(obj, cast)

Arguments

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