iterator_mod Module

module~~iterator_mod~~UsesGraph module~iterator_mod iterator_mod module~abstract_container_mod abstract_container_mod module~abstract_container_mod->module~iterator_mod iso_fortran_env iso_fortran_env iso_fortran_env->module~abstract_container_mod
Help

Provides the iterator data type which can be used to access a collection of data.

Used By

module~~iterator_mod~~UsedByGraph module~iterator_mod iterator_mod module~iterable_mod iterable_mod module~iterator_mod->module~iterable_mod module~ordered_mod ordered_mod module~iterator_mod->module~ordered_mod module~array_list_mod array_list_mod module~iterator_mod->module~array_list_mod module~iterable_mod->module~ordered_mod module~countable_mod countable_mod module~iterable_mod->module~countable_mod module~dynamic_set_mod dynamic_set_mod module~iterable_mod->module~dynamic_set_mod module~ordered_mod->module~array_list_mod module~queue_mod queue_mod module~ordered_mod->module~queue_mod module~data_set_mod data_set_mod module~array_list_mod->module~data_set_mod module~dictionary_mod dictionary_mod module~array_list_mod->module~dictionary_mod module~multimap_mod multimap_mod module~array_list_mod->module~multimap_mod module~countable_mod->module~ordered_mod module~countable_mod->module~data_set_mod module~multiset_mod multiset_mod module~dynamic_set_mod->module~multiset_mod module~data_set_mod->module~dynamic_set_mod module~data_set_mod->module~dictionary_mod module~dictionary_mod->module~multimap_mod module~map_mod map_mod module~dictionary_mod->module~map_mod module~map_mod->module~multimap_mod module~deque_mod deque_mod module~queue_mod->module~deque_mod module~list_mod list_mod module~deque_mod->module~list_mod module~list_mod->module~array_list_mod
Help

Interfaces

public interface iterator

  • private pure function constructor(contents) result(new)

    Arguments

    Type IntentOptional AttributesName
    class(container), intent(in), dimension(:):: contents

    Return Value type(iterator)

    Description

    Author
    Chris MacMackin
    Date
    March 2016

    Creates an iterator from an array of containers containing the data to be returned upon iteration. The data is returned starting with the first element of the array and ending with the last.


Derived Types

type, public :: iterator

Components

TypeVisibility AttributesNameInitial
class(container), private, allocatable, dimension(:):: contents
integer, private :: location =1
logical, private :: filled =.false.

Constructor

private pure function constructor(contents)

Creates an iterator from an array of containers containing the data to be returned upon iteration. The data is returned starting with the first element of the array and ending with the last.

Type-Bound Procedures

procedure, public :: has_next
procedure, public :: next
procedure, public :: reset
procedure, public :: contents_type

Description

A data type which provides a collection of data to the user. Objects of this type are returned using the iter method of FIAT's other data types. The contents of the iterator are set to be the same as the iterable at the time when the iter method was called. If new items are later added to the iterable object, this will not be reflected in the iterator object.


Functions

private pure function constructor(contents) result(new)

Arguments

Type IntentOptional AttributesName
class(container), intent(in), dimension(:):: contents

Return Value type(iterator)

Description

Author
Chris MacMackin
Date
March 2016

Creates an iterator from an array of containers containing the data to be returned upon iteration. The data is returned starting with the first element of the array and ending with the last.

private elemental function has_next(this)

Arguments

Type IntentOptional AttributesName
class(iterator), intent(in) :: this

Return Value logical

Whether there are additional items to iterate through

Description

Author
Chris MacMackin
Date
March 2016

Returns .true. if there are any remaining objects through which to iterate, and .false. otherwise.

private function next(this)

Arguments

Type IntentOptional AttributesName
class(iterator), intent(inout) :: this

Return Value class(container), allocatable

The next item held in the iterator, if present. Otherwise an unallocated container.

Description

Author
Chris MacMackin
Date
March 2016

Returns the next item stored in the iterator. If there are no more items present then an empty container is returned. If there are no contents stored in this iterator then it returns an unallocated container.

private pure function contents_type(this)

Arguments

Type IntentOptional AttributesName
class(iterator), intent(in) :: this

Return Value class(container), pointer

A container with the dynamic type of that used to hold the contents of the iterator. It is a pointer as pointer assignment is the easiest way to hold its "value" in an abstract variable.

Description

Author
Chris MacMackin
Date
March 2016

Returns a container with the dynamic type of that used to hold the contents of this iterator


Subroutines

private subroutine reset(this)

Arguments

Type IntentOptional AttributesName
class(iterator), intent(inout) :: this

Description

Author
Chris MacMackin
Date
March 2016

Resets the position of the iterator to the start, so it is as though the next routine has never been called.