FTMutableObjectArray is a mutable array class to which objects
can be added, removed, replaced and accessed according to their
index in the array.
Fortran has pointers to arrays, but not arrays of pointers. To do the latter, one creates
a wrapper derived type and creates an array of that wrapper type. Fortran arrays are great, but
they are of fixed length, and they don't easily implement reference counting to keep track of
memory. For that, we have the FTMutableObjectArray. Performance reasons dictate that you
will use regular arrays for numeric types and the like, but for generic objects we would use
an Object Array.
You initialize a FTMutableObjectArray with the number of objects that you expect it to hold.
However, it can re-size itself if necessary. To be efficient, it adds more than one entry at a time
given by the ``chunkSize'', which you can choose for yourself. (The default is 10.)
Definition
TYPE(FTMutableObjectArray) :: array
Usage
Initialization
CLASS(FTMutableObjectArray) :: array
INTEGER :: N = 11
CALL array % initWithSize(N)
Destruction
CALL array % destuct() [Non Pointers]
call release(array) [Pointers]
Adding an Object
TYPE(FTObject) :: obj
obj => r1
CALL array % addObject(obj)
Removing an Object
TYPE(FTObject) :: obj
CALL array % removeObjectAtIndex(i)
Accessing an Object
TYPE(FTObject) :: obj
obj => array % objectAtIndex(i)
Replacing an Object
TYPE(FTObject) :: obj
obj => r1
CALL array % replaceObjectAtIndexWithObject(i,obj)
Setting the Chunk Size
CALL array % setChunkSize(size)
Finding The Number Of Items In The Array
Finding The Actual Allocated Size Of The Array
n = array % allocatedSize()
Interfaces
-
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
Derived Types
Type-Bound Procedures
procedure, public ::
init => initFTObject |
|
procedure, public ::
description => FTObjectDescription |
|
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 => initObjectArrayWithSize |
|
procedure, public ::
destruct => destructObjectArray |
|
procedure, public ::
addObject => addObjectToArray |
|
procedure, public ::
replaceObjectAtIndexWithObject |
|
procedure, public ::
removeObjectAtIndex |
|
procedure, public ::
objectAtIndex |
|
procedure, public ::
printDescription => printArray |
|
procedure, public ::
className => arrayClassName |
|
procedure, public ::
setChunkSize |
|
procedure, public ::
chunkSize |
|
procedure, public ::
COUNT => numberOfItems |
|
procedure, public ::
allocatedSize |
|
Functions
Access the object at the index indx
Read more…
Arguments
Return Value
class(FTObject), POINTER
Returns the number of items to be added when the array needs to be re-sized
Read more…
Arguments
Return Value
integer
Generic name: count
Read more…
Arguments
Return Value
integer
Arguments
Return Value
integer
Generic Name: cast
Read more…
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
class(FTObject),
|
|
|
POINTER
|
:: |
obj |
|
Class name returns a string with the name of the type of the object
Read more…
Arguments
Return Value
character(len=CLASS_NAME_CHARACTER_LENGTH)
Subroutines
Designated initializer. Initializes the amount of storage, but
the array remains empty.
Read more…
Arguments
Destructor for the class. This is called automatically when the
reference count reaches zero. Do not call this yourself.
Arguments
Public, generic name: release(self)
Read more…
Arguments
Add an object to the end of the array
Read more…
Arguments
Remove an object at the index indx
Read more…
Arguments
Replace an object at the index indx
Read more…
Arguments
Set the number of items to be added when the array needs to be re-sized
Read more…
Arguments