FMUTIL  0.1
Fortran Miscellaneous UTILities
lists Module Reference

List module. More...

Data Types

type  list
 List type. More...
 
type  listitem
 List Item type. More...
 

Functions/Subroutines

pure integer function list_size (me)
 Returns the total number of items in the List. More...
 
integer function push_back (me, newitem)
 Subroutine to append an element at the back of the list. More...
 
class(*) function, allocatable pop_back (me)
 Function to extract the last item of List. More...
 
class(*) function, pointer item_at (me, Index)
 Returns a pointer to the item with the requested index (1-based) Pointer will not be associated in case of an exception. More...
 
class(*) function, allocatable item_front (me)
 Returns the item with the index=1. More...
 
class(*) function, allocatable item_back (me)
 Returns the last item in List. More...
 
subroutine item_insert (me, pos, NewItem)
 Inserts an item at the given position. More...
 
subroutine item_erase (me, pos)
 Erase an item at the given position. More...
 
subroutine create_newslots (me, NumSlots)
 Subroutine to allocate storage for new slots. More...
 
subroutine assignlist (lhs, rhs)
 Subroutine for List assignment operator. More...
 
subroutine clear (me)
 Clear the contents of List. More...
 
subroutine shrinktofit (me)
 Free up unused allocated memory and make List capacity equal to its size. More...
 
subroutine destroy (me)
 Destructor. More...
 
elemental subroutine add_listitem (me, item)
 
subroutine del_listitem (me)
 
pure elemental logical function isvalid_listitem (me)
 

Variables

integer, parameter default_newslotsallocated = 5
 Default number of slots to create on list capacity increase. More...
 

Detailed Description

List module.

This module provides the list data structure (similar to Python list) represented internally using an array.

Author
Bharat Mahajan
Date
Created: 05/27/2020

Function/Subroutine Documentation

◆ add_listitem()

elemental subroutine lists::add_listitem ( class(listitem), intent(inout)  me,
class(*), intent(in)  item 
)
private
Parameters
[in]itemnew item to be allocated

Definition at line 428 of file list.f90.

◆ assignlist()

subroutine lists::assignlist ( class(list), intent(out)  lhs,
class(list), intent(in)  rhs 
)
private

Subroutine for List assignment operator.

Definition at line 336 of file list.f90.

Referenced by lists::list::assignment().

+ Here is the caller graph for this function:

◆ clear()

subroutine lists::clear ( class(list), intent(inout)  me)
private

Clear the contents of List.

Definition at line 366 of file list.f90.

◆ create_newslots()

subroutine lists::create_newslots ( class(list), intent(inout)  me,
integer, intent(in)  NumSlots 
)
private

Subroutine to allocate storage for new slots.

Parameters
[in]numslotsNumber of slots to create

Definition at line 308 of file list.f90.

◆ del_listitem()

subroutine lists::del_listitem ( class(listitem), intent(inout)  me)
private

Definition at line 448 of file list.f90.

◆ destroy()

subroutine lists::destroy ( type(list), intent(inout)  me)
private

Destructor.

Definition at line 412 of file list.f90.

Referenced by lists::list::destroy().

+ Here is the caller graph for this function:

◆ isvalid_listitem()

pure elemental logical function lists::isvalid_listitem ( class(listitem), intent(in)  me)
private

Definition at line 459 of file list.f90.

◆ item_at()

class(*) function, pointer lists::item_at ( class(list), intent(inout), target  me,
integer, intent(in)  Index 
)
private

Returns a pointer to the item with the requested index (1-based) Pointer will not be associated in case of an exception.

Parameters
[in]indexIndex of the requested item

Definition at line 203 of file list.f90.

◆ item_back()

class(*) function, allocatable lists::item_back ( class(list), intent(inout)  me)
private

Returns the last item in List.

Definition at line 234 of file list.f90.

◆ item_erase()

subroutine lists::item_erase ( class(list), intent(inout)  me,
integer, intent(in)  pos 
)
private

Erase an item at the given position.

Definition at line 280 of file list.f90.

◆ item_front()

class(*) function, allocatable lists::item_front ( class(list), intent(inout)  me)
private

Returns the item with the index=1.

Definition at line 222 of file list.f90.

◆ item_insert()

subroutine lists::item_insert ( class(list), intent(inout)  me,
integer, intent(in)  pos,
class(*), intent(in)  NewItem 
)
private

Inserts an item at the given position.

Definition at line 245 of file list.f90.

◆ list_size()

pure integer function lists::list_size ( class(list), intent(in)  me)

Returns the total number of items in the List.

Definition at line 147 of file list.f90.

◆ pop_back()

class(*) function, allocatable lists::pop_back ( class(list), intent(inout)  me)
private

Function to extract the last item of List.

Definition at line 187 of file list.f90.

◆ push_back()

integer function lists::push_back ( class(list), intent(inout)  me,
class(*), intent(in)  newitem 
)
private

Subroutine to append an element at the back of the list.

Parameters
[in]newitemitem to add to the list
Returns
0 on error, otherwise returns the position of the element

Definition at line 161 of file list.f90.

◆ shrinktofit()

subroutine lists::shrinktofit ( class(list), intent(inout)  me)
private

Free up unused allocated memory and make List capacity equal to its size.

Definition at line 381 of file list.f90.

Variable Documentation

◆ default_newslotsallocated

integer, parameter lists::default_newslotsallocated = 5
private

Default number of slots to create on list capacity increase.

Definition at line 40 of file list.f90.