361 lines
No EOL
30 KiB
HTML
361 lines
No EOL
30 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="description" content="RPN calculator in modern Fortran">
|
|
<meta name="author" content="sgeard" >
|
|
<link rel="icon" href="../favicon.png">
|
|
|
|
<title>linked_list.f90 – hp</title>
|
|
|
|
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="../css/pygments.css" rel="stylesheet">
|
|
<link href="../css/font-awesome.min.css" rel="stylesheet">
|
|
<link href="../css/local.css" rel="stylesheet">
|
|
<link href="../tipuesearch/tipuesearch.css" rel="stylesheet">
|
|
|
|
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
|
<!--[if lt IE 9]>
|
|
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
|
<![endif]-->
|
|
|
|
<script src="../js/jquery-2.1.3.min.js"></script>
|
|
<script src="../js/svg-pan-zoom.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<!-- Fixed navbar -->
|
|
<nav class="navbar navbar-inverse navbar-fixed-top">
|
|
<div class="container">
|
|
<div class="navbar-header">
|
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
|
<span class="sr-only">Toggle navigation</span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
</button>
|
|
<a class="navbar-brand" href="../index.html">hp </a>
|
|
</div>
|
|
<div id="navbar" class="navbar-collapse collapse">
|
|
<ul class="nav navbar-nav">
|
|
<li class="dropdown hidden-xs visible-sm visible-md hidden-lg">
|
|
<a href="#" class="dropdown-toggle"
|
|
data-toggle="dropdown" role="button"
|
|
aria-haspopup="true"
|
|
aria-expanded="false">Contents <span class="caret"></span></a>
|
|
<ul class="dropdown-menu">
|
|
<li><a href="../lists/files.html">Source Files</a></li>
|
|
<li><a href="../lists/modules.html">Modules</a></li>
|
|
<li><a href="../lists/procedures.html">Procedures</a></li>
|
|
<li><a href="../lists/absint.html">Abstract Interfaces</a></li>
|
|
<li><a href="../lists/types.html">Derived Types</a></li>
|
|
<li><a href="../lists/programs.html">Programs</a></li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/files.html">Source Files</a></li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/modules.html">Modules</a></li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/procedures.html">Procedures</a></li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/absint.html">Abstract Interfaces</a></li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/types.html">Derived Types</a></li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/programs.html">Programs</a></li>
|
|
</ul>
|
|
<form action="../search.html" class="navbar-form navbar-right" role="search">
|
|
<div class="form-group">
|
|
<input type="text" class="form-control" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required>
|
|
</div>
|
|
<!--
|
|
<button type="submit" class="btn btn-default">Submit</button>
|
|
-->
|
|
</form>
|
|
</div><!--/.nav-collapse -->
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container">
|
|
<div class="row">
|
|
<h1>linked_list.f90
|
|
<small>Source File</small>
|
|
|
|
</h1>
|
|
<div class="row" id="info-bar">
|
|
<div class="col-lg-12">
|
|
<div class="well well-sm">
|
|
<ul class="list-inline" style="margin-bottom:0px;display:inline">
|
|
|
|
<li id="statements"><i class="fa fa-list-ol"></i>
|
|
<a data-toggle="tooltip"
|
|
data-placement="bottom" data-html="true"
|
|
title=" 4.1% of total for source files.">85 statements</a>
|
|
</li>
|
|
|
|
<li id="source-file">
|
|
<i class="fa fa-code"></i>
|
|
<a href="../src/linked_list.f90"> Source File</a>
|
|
</li>
|
|
</ul>
|
|
<ol class="breadcrumb in-well text-right">
|
|
<li class="active">linked_list.f90</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
$(function () {
|
|
$('[data-toggle="tooltip"]').tooltip()
|
|
})
|
|
</script>
|
|
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-3 hidden-xs hidden-sm visible-md visible-lg">
|
|
<div id="sidebar">
|
|
<h3>Contents</h3>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="panel panel-primary">
|
|
<div class="panel-heading text-left">
|
|
<h3 class="panel-title">
|
|
<a data-toggle="collapse" href="#mods-0">Modules</a>
|
|
</h3>
|
|
</div>
|
|
<div id="mods-0" class="panel-collapse collapse">
|
|
<div class="list-group">
|
|
<a class="list-group-item" href="../module/linked_list.html">linked_list</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="panel panel-primary">
|
|
<div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
|
|
<div class="list-group">
|
|
<a class="list-group-item" href="../sourcefile/linked_list.f90.html#src">linked_list.f90</a>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<div class="col-md-9" id='text'>
|
|
|
|
<br>
|
|
|
|
<section class="visible-xs visible-sm hidden-md">
|
|
<h3>Contents</h3>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="panel panel-primary">
|
|
<div class="panel-heading text-left">
|
|
<h3 class="panel-title">
|
|
<a data-toggle="collapse" href="#mods-1">Modules</a>
|
|
</h3>
|
|
</div>
|
|
<div id="mods-1" class="panel-collapse collapse">
|
|
<div class="list-group">
|
|
<a class="list-group-item" href="../module/linked_list.html">linked_list</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="panel panel-primary">
|
|
<div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
|
|
<div class="list-group">
|
|
<a class="list-group-item" href="../sourcefile/linked_list.f90.html#src">linked_list.f90</a>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</section>
|
|
<br class="visible-xs visible-sm hidden-md">
|
|
|
|
<section>
|
|
<h2><span class="anchor" id="src"></span>Source Code</h2>
|
|
<div class="hl"><pre><span></span><a id="ln-1" name="ln-1" href="#ln-1"></a><span class="k">module </span><span class="n">linked_list</span><span class="w"></span>
|
|
<a id="ln-2" name="ln-2" href="#ln-2"></a><span class="w"> </span><span class="k">public</span>
|
|
<a id="ln-3" name="ln-3" href="#ln-3"></a><span class="k"> </span>
|
|
<a id="ln-4" name="ln-4" href="#ln-4"></a><span class="k"> type </span><span class="n">llist</span><span class="w"></span>
|
|
<a id="ln-5" name="ln-5" href="#ln-5"></a><span class="w"> </span><span class="k">private</span>
|
|
<a id="ln-6" name="ln-6" href="#ln-6"></a><span class="k"> type</span><span class="p">(</span><span class="n">llist_node</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">begin</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span><span class="w"></span>
|
|
<a id="ln-7" name="ln-7" href="#ln-7"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">llist_node</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="k">end</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span><span class="w"></span>
|
|
<a id="ln-8" name="ln-8" href="#ln-8"></a><span class="w"> </span><span class="k">contains</span>
|
|
<a id="ln-9" name="ln-9" href="#ln-9"></a><span class="k"> procedure</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">iterate</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">iterate_ll</span><span class="w"></span>
|
|
<a id="ln-10" name="ln-10" href="#ln-10"></a><span class="w"> </span><span class="k">end type </span><span class="n">llist</span><span class="w"></span>
|
|
<a id="ln-11" name="ln-11" href="#ln-11"></a><span class="w"> </span>
|
|
<a id="ln-12" name="ln-12" href="#ln-12"></a><span class="w"> </span><span class="k">type </span><span class="n">llist_node</span><span class="w"></span>
|
|
<a id="ln-13" name="ln-13" href="#ln-13"></a><span class="w"> </span><span class="k">private</span>
|
|
<a id="ln-14" name="ln-14" href="#ln-14"></a><span class="k"> </span><span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="p">:),</span><span class="w"> </span><span class="k">allocatable</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="k">data</span>
|
|
<a id="ln-15" name="ln-15" href="#ln-15"></a><span class="k"> type</span><span class="p">(</span><span class="n">llist_node</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">next</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span><span class="w"></span>
|
|
<a id="ln-16" name="ln-16" href="#ln-16"></a><span class="w"> </span><span class="k">end type </span><span class="n">llist_node</span><span class="w"></span>
|
|
<a id="ln-17" name="ln-17" href="#ln-17"></a>
|
|
<a id="ln-18" name="ln-18" href="#ln-18"></a><span class="w"> </span><span class="c">! Interface for functions being applied to each list element in turn</span>
|
|
<a id="ln-19" name="ln-19" href="#ln-19"></a><span class="w"> </span><span class="c">! when iterating</span>
|
|
<a id="ln-20" name="ln-20" href="#ln-20"></a><span class="w"> </span><span class="k">abstract interface</span>
|
|
<a id="ln-21" name="ln-21" href="#ln-21"></a><span class="k"> subroutine </span><span class="n">command_fun</span><span class="p">(</span><span class="n">command</span><span class="p">,</span><span class="w"> </span><span class="n">ok</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-22" name="ln-22" href="#ln-22"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">command</span><span class="w"></span>
|
|
<a id="ln-23" name="ln-23" href="#ln-23"></a><span class="w"> </span><span class="kt">logical</span><span class="p">,</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">ok</span><span class="w"> </span><span class="c">! Exit the loop if not true</span>
|
|
<a id="ln-24" name="ln-24" href="#ln-24"></a><span class="w"> </span><span class="k">end subroutine </span><span class="n">command_fun</span><span class="w"></span>
|
|
<a id="ln-25" name="ln-25" href="#ln-25"></a><span class="w"> </span><span class="k">end interface</span>
|
|
<a id="ln-26" name="ln-26" href="#ln-26"></a>
|
|
<a id="ln-27" name="ln-27" href="#ln-27"></a><span class="k"> </span>
|
|
<a id="ln-28" name="ln-28" href="#ln-28"></a><span class="k">contains</span>
|
|
<a id="ln-29" name="ln-29" href="#ln-29"></a>
|
|
<a id="ln-30" name="ln-30" href="#ln-30"></a><span class="k"> function </span><span class="n">iterate_ll</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">f</span><span class="p">)</span><span class="w"> </span><span class="k">result</span><span class="p">(</span><span class="n">r</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-31" name="ln-31" href="#ln-31"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="n">llist</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">),</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">this</span><span class="w"></span>
|
|
<a id="ln-32" name="ln-32" href="#ln-32"></a><span class="w"> </span><span class="k">procedure</span><span class="p">(</span><span class="n">command_fun</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">f</span><span class="w"></span>
|
|
<a id="ln-33" name="ln-33" href="#ln-33"></a><span class="w"> </span><span class="kt">logical</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">r</span><span class="w"></span>
|
|
<a id="ln-34" name="ln-34" href="#ln-34"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">llist_node</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">token</span><span class="w"></span>
|
|
<a id="ln-35" name="ln-35" href="#ln-35"></a><span class="w"> </span><span class="n">token</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">this</span><span class="p">%</span><span class="n">begin</span><span class="w"></span>
|
|
<a id="ln-36" name="ln-36" href="#ln-36"></a><span class="w"> </span><span class="k">do</span>
|
|
<a id="ln-37" name="ln-37" href="#ln-37"></a><span class="k"> if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="n">token</span><span class="p">))</span><span class="w"> </span><span class="k">exit</span>
|
|
<a id="ln-38" name="ln-38" href="#ln-38"></a><span class="k"> call </span><span class="n">f</span><span class="p">(</span><span class="nb">trim</span><span class="p">(</span><span class="n">token</span><span class="p">%</span><span class="k">data</span><span class="p">),</span><span class="w"> </span><span class="n">r</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-39" name="ln-39" href="#ln-39"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="n">r</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<a id="ln-40" name="ln-40" href="#ln-40"></a><span class="k"> exit</span>
|
|
<a id="ln-41" name="ln-41" href="#ln-41"></a><span class="k"> end if</span>
|
|
<a id="ln-42" name="ln-42" href="#ln-42"></a><span class="k"> </span><span class="n">token</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">token</span><span class="p">%</span><span class="n">next</span><span class="w"></span>
|
|
<a id="ln-43" name="ln-43" href="#ln-43"></a><span class="w"> </span><span class="k">end do</span>
|
|
<a id="ln-44" name="ln-44" href="#ln-44"></a><span class="k"> end function </span><span class="n">iterate_ll</span><span class="w"></span>
|
|
<a id="ln-45" name="ln-45" href="#ln-45"></a><span class="w"> </span>
|
|
<a id="ln-46" name="ln-46" href="#ln-46"></a><span class="w"> </span><span class="k">subroutine </span><span class="n">append</span><span class="p">(</span><span class="n">lst</span><span class="p">,</span><span class="w"> </span><span class="k">data</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-47" name="ln-47" href="#ln-47"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">llist</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">lst</span><span class="w"></span>
|
|
<a id="ln-48" name="ln-48" href="#ln-48"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="k">data</span>
|
|
<a id="ln-49" name="ln-49" href="#ln-49"></a><span class="k"> if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="n">lst</span><span class="p">%</span><span class="n">begin</span><span class="p">))</span><span class="w"> </span><span class="k">then</span>
|
|
<a id="ln-50" name="ln-50" href="#ln-50"></a><span class="k"> allocate</span><span class="p">(</span><span class="n">lst</span><span class="p">%</span><span class="n">begin</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-51" name="ln-51" href="#ln-51"></a><span class="w"> </span><span class="n">lst</span><span class="p">%</span><span class="n">begin</span><span class="p">%</span><span class="k">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">data</span>
|
|
<a id="ln-52" name="ln-52" href="#ln-52"></a><span class="k"> </span><span class="n">lst</span><span class="p">%</span><span class="k">end</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">lst</span><span class="p">%</span><span class="n">begin</span><span class="w"></span>
|
|
<a id="ln-53" name="ln-53" href="#ln-53"></a><span class="w"> </span><span class="k">else</span>
|
|
<a id="ln-54" name="ln-54" href="#ln-54"></a><span class="k"> allocate</span><span class="p">(</span><span class="n">lst</span><span class="p">%</span><span class="k">end</span><span class="p">%</span><span class="n">next</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-55" name="ln-55" href="#ln-55"></a><span class="w"> </span><span class="n">lst</span><span class="p">%</span><span class="k">end</span><span class="p">%</span><span class="n">next</span><span class="p">%</span><span class="k">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">data</span>
|
|
<a id="ln-56" name="ln-56" href="#ln-56"></a><span class="k"> </span><span class="n">lst</span><span class="p">%</span><span class="k">end</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">lst</span><span class="p">%</span><span class="k">end</span><span class="p">%</span><span class="n">next</span><span class="w"></span>
|
|
<a id="ln-57" name="ln-57" href="#ln-57"></a><span class="w"> </span><span class="k">end if</span>
|
|
<a id="ln-58" name="ln-58" href="#ln-58"></a><span class="k"> end subroutine </span><span class="n">append</span><span class="w"></span>
|
|
<a id="ln-59" name="ln-59" href="#ln-59"></a>
|
|
<a id="ln-60" name="ln-60" href="#ln-60"></a><span class="w"> </span><span class="k">subroutine print</span><span class="p">(</span><span class="n">lst</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-61" name="ln-61" href="#ln-61"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">llist</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">lst</span><span class="w"></span>
|
|
<a id="ln-62" name="ln-62" href="#ln-62"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">llist_node</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">next</span><span class="w"></span>
|
|
<a id="ln-63" name="ln-63" href="#ln-63"></a><span class="w"> </span><span class="k">write</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="s1">'(a)'</span><span class="p">)</span><span class="w"> </span><span class="s1">'Tokens:'</span><span class="w"></span>
|
|
<a id="ln-64" name="ln-64" href="#ln-64"></a><span class="w"> </span><span class="n">next</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">lst</span><span class="p">%</span><span class="n">begin</span><span class="w"></span>
|
|
<a id="ln-65" name="ln-65" href="#ln-65"></a><span class="w"> </span><span class="k">do</span>
|
|
<a id="ln-66" name="ln-66" href="#ln-66"></a><span class="k"> if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="n">next</span><span class="p">))</span><span class="w"> </span><span class="k">exit</span>
|
|
<a id="ln-67" name="ln-67" href="#ln-67"></a><span class="k"> write</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="s1">'(4x,a)'</span><span class="p">)</span><span class="w"> </span><span class="n">next</span><span class="p">%</span><span class="k">data</span>
|
|
<a id="ln-68" name="ln-68" href="#ln-68"></a><span class="k"> </span><span class="n">next</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">next</span><span class="p">%</span><span class="n">next</span><span class="w"></span>
|
|
<a id="ln-69" name="ln-69" href="#ln-69"></a><span class="w"> </span><span class="k">end do</span>
|
|
<a id="ln-70" name="ln-70" href="#ln-70"></a><span class="k"> end subroutine print</span>
|
|
<a id="ln-71" name="ln-71" href="#ln-71"></a>
|
|
<a id="ln-72" name="ln-72" href="#ln-72"></a><span class="k"> </span><span class="kt">integer </span><span class="k">function </span><span class="n">size</span><span class="p">(</span><span class="n">lst</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-73" name="ln-73" href="#ln-73"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">llist</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">lst</span><span class="w"></span>
|
|
<a id="ln-74" name="ln-74" href="#ln-74"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">llist_node</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">this</span><span class="w"></span>
|
|
<a id="ln-75" name="ln-75" href="#ln-75"></a><span class="w"> </span><span class="n">size</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="w"></span>
|
|
<a id="ln-76" name="ln-76" href="#ln-76"></a><span class="w"> </span><span class="n">this</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">lst</span><span class="p">%</span><span class="n">begin</span><span class="w"></span>
|
|
<a id="ln-77" name="ln-77" href="#ln-77"></a><span class="w"> </span><span class="k">do</span>
|
|
<a id="ln-78" name="ln-78" href="#ln-78"></a><span class="k"> if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="n">this</span><span class="p">))</span><span class="w"> </span><span class="k">exit</span>
|
|
<a id="ln-79" name="ln-79" href="#ln-79"></a><span class="k"> </span><span class="n">size</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">size</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"></span>
|
|
<a id="ln-80" name="ln-80" href="#ln-80"></a><span class="w"> </span><span class="n">this</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">this</span><span class="p">%</span><span class="n">next</span><span class="w"></span>
|
|
<a id="ln-81" name="ln-81" href="#ln-81"></a><span class="w"> </span><span class="k">end do</span>
|
|
<a id="ln-82" name="ln-82" href="#ln-82"></a><span class="k"> end function </span><span class="n">size</span><span class="w"></span>
|
|
<a id="ln-83" name="ln-83" href="#ln-83"></a>
|
|
<a id="ln-84" name="ln-84" href="#ln-84"></a><span class="w"> </span><span class="k">subroutine </span><span class="n">clear</span><span class="p">(</span><span class="n">lst</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-85" name="ln-85" href="#ln-85"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">llist</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">lst</span><span class="w"></span>
|
|
<a id="ln-86" name="ln-86" href="#ln-86"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">llist_node</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">next</span><span class="w"></span>
|
|
<a id="ln-87" name="ln-87" href="#ln-87"></a><span class="w"> </span><span class="n">this</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">lst</span><span class="p">%</span><span class="n">begin</span><span class="w"></span>
|
|
<a id="ln-88" name="ln-88" href="#ln-88"></a><span class="w"> </span><span class="k">do</span>
|
|
<a id="ln-89" name="ln-89" href="#ln-89"></a><span class="k"> if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="n">this</span><span class="p">))</span><span class="w"> </span><span class="k">exit</span>
|
|
<a id="ln-90" name="ln-90" href="#ln-90"></a><span class="k"> </span><span class="n">next</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">this</span><span class="p">%</span><span class="n">next</span><span class="w"></span>
|
|
<a id="ln-91" name="ln-91" href="#ln-91"></a><span class="w"> </span><span class="k">deallocate</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-92" name="ln-92" href="#ln-92"></a><span class="w"> </span><span class="n">this</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">next</span><span class="w"></span>
|
|
<a id="ln-93" name="ln-93" href="#ln-93"></a><span class="w"> </span><span class="k">end do</span>
|
|
<a id="ln-94" name="ln-94" href="#ln-94"></a><span class="k"> nullify</span><span class="p">(</span><span class="n">lst</span><span class="p">%</span><span class="k">end</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-95" name="ln-95" href="#ln-95"></a><span class="w"> </span><span class="k">nullify</span><span class="p">(</span><span class="n">lst</span><span class="p">%</span><span class="n">begin</span><span class="p">)</span><span class="w"></span>
|
|
<a id="ln-96" name="ln-96" href="#ln-96"></a><span class="w"> </span><span class="k">end subroutine </span><span class="n">clear</span><span class="w"></span>
|
|
<a id="ln-97" name="ln-97" href="#ln-97"></a><span class="k">end module </span><span class="n">linked_list</span><span class="w"></span>
|
|
</pre></div>
|
|
|
|
</section>
|
|
</div>
|
|
</div>
|
|
|
|
<hr>
|
|
</div> <!-- /container -->
|
|
<footer>
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-xs-6 col-md-6"><p>hp was developed by sgeard<br>© 2023
|
|
</p>
|
|
</div>
|
|
<div class="col-xs-6 col-md-6">
|
|
<p class="text-right">
|
|
Documentation generated by
|
|
<a href="https://github.com/Fortran-FOSS-Programmers/ford">FORD</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<br>
|
|
</div> <!-- /container -->
|
|
</footer>
|
|
|
|
<!-- Bootstrap core JavaScript
|
|
================================================== -->
|
|
<!-- Placed at the end of the document so the pages load faster -->
|
|
<!--
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
|
-->
|
|
<script src="../js/bootstrap.min.js"></script>
|
|
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
|
<script src="../js/ie10-viewport-bug-workaround.js"></script>
|
|
|
|
<!-- MathJax JavaScript
|
|
================================================== -->
|
|
<!-- Placed at the end of the document so the pages load faster -->
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({
|
|
TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'], equationNumbers: { autoNumber: 'AMS' } },
|
|
jax: ['input/TeX','input/MathML','output/HTML-CSS'],
|
|
extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']
|
|
});
|
|
</script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
|
|
|
<script src="../tipuesearch/tipuesearch_content.js"></script>
|
|
<script src="../tipuesearch/tipuesearch_set.js"></script>
|
|
<script src="../tipuesearch/tipuesearch.js"></script>
|
|
|
|
</body>
|
|
</html> |