FTStackClass Module

Inherits from FTLinkedListClass : FTObjectClass

Definition (Subclass of FTLinkedListClass):

TYPE(FTStack) :: list

Usage:

Initialization

  ALLOCATE(stack)  If stack is a pointer
  CALL stack  %  init()

Destruction

  CALL release(stack) [Pointers]
  CALL stack % destruct() [Non pointers]

Pushing an object onto the stack

  TYPE(FTObject) :: objectPtr
  objectPtr => r1
  CALL stack % push(objectPtr)

Peeking at the top of the stack

  objectPtr => stack % peek()  No change of ownership
  SELECT TYPE(objectPtr)
     TYPE is (*SubclassType*)
         Do something with ObjectPtr as subclass
     CLASS DEFAULT
         Problem with casting
  END SELECT

Popping the top of the stack

  objectPtr => stack % pop()  Ownership transferred to caller
  SELECT TYPE(objectPtr)
     TYPE is (*SubclassType*)
         Do something with ObjectPtr as subclass
     CLASS DEFAULT
         Problem with casting
  END SELECT


Interfaces

public interface release

  • public subroutine releaseFTStack(self)

    Public, generic name: release(self)

    Call release(self) on an object to release control of a pointer object. If its reference count is zero, then it is deallocated.

    Arguments

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

Derived Types

type, public, extends(FTLinkedList) ::  FTStack

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 :: 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 :: allObjects => allLinkedListObjects
procedure, public :: removeAllObjects => removeAllLinkedListObjects
procedure, public :: addObjectsFromList
procedure, public :: makeCircular
procedure, public :: isCircular
procedure, public :: insertObjectAfterRecord
procedure, public :: insertObjectAfterObject
procedure, public :: init => initFTStack
procedure, public :: printDescription => printStackDescription
procedure, public :: className => stackClassName
procedure, public :: push
procedure, public :: pop
procedure, public :: peek

Functions

public function peek(self)

Arguments

Type IntentOptional Attributes Name
class(FTStack) :: self

Return Value class(FTObject), POINTER

public function stackFromObject(obj) result(cast)

Arguments

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

Return Value class(FTStack), POINTER

public function stackClassName(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(FTStack) :: self

Return Value character(len=CLASS_NAME_CHARACTER_LENGTH)


Subroutines

public subroutine initFTStack(self)

Public, generic name: init()

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTStack) :: self

public subroutine releaseFTStack(self)

Public, generic name: release(self)

Read more…

Arguments

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

public subroutine push(self, obj)

Arguments

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

public subroutine pop(self, p)

Arguments

Type IntentOptional Attributes Name
class(FTStack) :: self
class(FTObject), POINTER :: p

public subroutine printStackDescription(self, iUnit)

Arguments

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