Sha256: 0079cc2c432b29ad41aa3b82fcabc4807a121949e1ee7185a5fec27da76e16f9

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title>insert_or_extrude (Glue::Cache::Strategy::LFU)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
.ruby-comment    { color: green; font-style: italic }
.ruby-constant   { color: #4433aa; font-weight: bold; }
.ruby-identifier { color: #222222;  }
.ruby-ivar       { color: #2233dd; }
.ruby-keyword    { color: #3333FF; font-weight: bold }
.ruby-node       { color: #777777; }
.ruby-operator   { color: #111111;  }
.ruby-regexp     { color: #662222; }
.ruby-value      { color: #662222; font-style: italic }
  .kw { color: #3333FF; font-weight: bold }
  .cmt { color: green; font-style: italic }
  .str { color: #662222; font-style: italic }
  .re  { color: #662222; }
</style>
</head>
<body bgcolor="white">
<pre><span class="ruby-comment cmt"># File lib/mega/cache.rb, line 78</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">insert_or_extrude</span>(<span class="ruby-identifier">item</span>, <span class="ruby-identifier">enum</span>)
    <span class="ruby-comment cmt"># find least recently used key/item and yield</span>
    <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">enum</span>.<span class="ruby-identifier">min_by</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">it</span><span class="ruby-operator">|</span> <span class="ruby-identifier">it</span>.<span class="ruby-identifier">freq</span>} <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">full?</span>
    <span class="ruby-identifier">item</span>.<span class="ruby-identifier">freq</span> = <span class="ruby-value">0</span> 
    <span class="ruby-identifier">inc</span>(<span class="ruby-identifier">item</span>)
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mega-0.3.1 pub/www/doc/classes/Glue/Cache/Strategy/LFU.src/M000695.html