Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/datastructures/doc/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 14.9.2025 mit Größe 5 kB image not shown  

Quelle  chap9_mj.html   Sprache: HTML

 
 products/Sources/formale Sprachen/GAP/pkg/datastructures/doc/chap9_mj.html


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<title>GAP (datastructures) - Chapter 9: Memoisation</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap9"  onload="jscontent()">


<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0_mj.html">Top</a>  <a href="chap1_mj.html">1</a>  <a href="chap2_mj.html">2</a>  <a href="chap3_mj.html">3</a>  <a href="chap4_mj.html">4</a>  <a href="chap5_mj.html">5</a>  <a href="chap6_mj.html">6</a>  <a href="chap7_mj.html">7</a>  <a href="chap8_mj.html">8</a>  <a href="chap9_mj.html">9</a>  <a href="chap10_mj.html">10</a>  <a href="chap11_mj.html">11</a>  <a href="chap12_mj.html">12</a>  <a href="chapBib_mj.html">Bib</a>  <a href="chapInd_mj.html">Ind</a>  </div>

<div class="chlinkprevnexttop"> <a href="chap0_mj.html">[Top of Book]</a>   <a href="chap0_mj.html#contents">[Contents]</a>    <a href="chap8_mj.html">[Previous Chapter]</a>    <a href="chap10_mj.html">[Next Chapter]</a>   </div>

<p id="mathjaxlink" class="pcenter"><a href="chap9.html">[MathJax off]</a></p>
<p><a id="X8693FF6287BAAB84" name="X8693FF6287BAAB84"></a></p>
<div class="ChapSects"><a href="chap9_mj.html#X8693FF6287BAAB84">9 <span class="Heading">Memoisation</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9_mj.html#X8779C9D987C7B094">9.1 <span class="Heading">Memoisation with HashMap</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9_mj.html#X7E7224D77AFAFE00">9.1-1 MemoizeFunction</a></span>
</div></div>
</div>

<h3>9 <span class="Heading">Memoisation</span></h3>

<p><strong class="pkg">datastructures</strong> provides simple ways to cache return values of pure functions.</p>

<p><a id="X8779C9D987C7B094" name="X8779C9D987C7B094"></a></p>

<h4>9.1 <span class="Heading">Memoisation with HashMap</span></h4>

<p><a id="X7E7224D77AFAFE00" name="X7E7224D77AFAFE00"></a></p>

<h5>9.1-1 MemoizeFunction</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MemoizeFunction</code>( <var class="Arg">function</var>[, <var class="Arg">options</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: A function</p>

<p><code class="code">MemoizeFunction</code> returns a function which behaves the same as <var class="Arg">function</var>, except that it caches the return value of <var class="Arg">function</var>. The cache can be flushed by calling <code class="func">FlushCaches</code> (<a href="/home/runner/gap/doc/ref/chap79_mj.html#X87A4316C818B3DE3"><span class="RefLink">Reference: FlushCaches</span></a>).</p>

<p>This function does not promise to never call <var class="Arg">function</var> more than once for any input -- values may be removed if the cache gets too large, or GAP chooses to flush all caches, or if multiple threads try to calculate the same value simultaneously.</p>

<p>The optional second argument is a record which provides a number of configuration options. The following options are supported.</p>


<dl>
<dt><strong class="Mark"><code class="code">flush</code> (default <code class="keyw">true</code>)</strong></dt>
<dd><p>If this is <code class="keyw">true</code>, the cache is emptied whenever <code class="func">FlushCaches</code> (<a href="/home/runner/gap/doc/ref/chap79_mj.html#X87A4316C818B3DE3"><span class="RefLink">Reference: FlushCaches</span></a>) is called.</p>

</dd>
<dt><strong class="Mark"><code class="code">contract</code> (defaults to <code class="func">ReturnTrue</code> (<a href="/home/runner/gap/doc/ref/chap5_mj.html#X7DB422A2876CCC4D"><span class="RefLink">Reference: ReturnTrue</span></a>))</strong></dt>
<dd><p>A function that is called on the arguments given to <var class="Arg">function</var>. If this function returns <code class="keyw">false</code>, then <code class="code">errorHandler</code> is called.</p>

</dd>
<dt><strong class="Mark"><code class="code">errorHandler</code> (defaults to none)</strong></dt>
<dd><p>A function to be called when an input that does not fulfil <code class="code">contract</code> is passed to the cache.</p>

</dd>
</dl>

<div class="chlinkprevnextbot"> <a href="chap0_mj.html">[Top of Book]</a>   <a href="chap0_mj.html#contents">[Contents]</a>    <a href="chap8_mj.html">[Previous Chapter]</a>    <a href="chap10_mj.html">[Next Chapter]</a>   </div>


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0_mj.html">Top</a>  <a href="chap1_mj.html">1</a>  <a href="chap2_mj.html">2</a>  <a href="chap3_mj.html">3</a>  <a href="chap4_mj.html">4</a>  <a href="chap5_mj.html">5</a>  <a href="chap6_mj.html">6</a>  <a href="chap7_mj.html">7</a>  <a href="chap8_mj.html">8</a>  <a href="chap9_mj.html">9</a>  <a href="chap10_mj.html">10</a>  <a href="chap11_mj.html">11</a>  <a href="chap12_mj.html">12</a>  <a href="chapBib_mj.html">Bib</a>  <a href="chapInd_mj.html">Ind</a>  </div>

<hr />
<p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>

100%


¤ Dauer der Verarbeitung: 0.2 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.