Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 3439

Macaulay2-1.3.1-8.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8" ?>  <!-- for emacs: -*- coding: utf-8 -*- -->
<!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"	 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>Database -- the class of all database files</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="___Database_sp_sh_sp__String.html">next</a> | <a href="_current__Time.html">previous</a> | <a href="___Database_sp_sh_sp__String.html">forward</a> | <a href="_current__Time.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div>

    </td>
  </tr>
</table>
<hr/>
<div><h1>Database -- the class of all database files</h1>
<div class="single"><h2>Description</h2>
<div>A database file is just like a hash table, except both the keys and values have to be strings.  In this example we create a database file, store a few entries, remove an entry with <a href="_remove.html" title="remove an entry from a hash table">remove</a>, close the file, and then remove the file.<table class="examples"><tr><td><pre>i1 : filename = temporaryFileName () | ".dbm"

o1 = /tmp/M2-22058-1.dbm</pre>
</td></tr>
<tr><td><pre>i2 : x = openDatabaseOut filename

o2 = /tmp/M2-22058-1.dbm

o2 : Database</pre>
</td></tr>
<tr><td><pre>i3 : x#"first" = "hi there"

o3 = hi there</pre>
</td></tr>
<tr><td><pre>i4 : x#"first"

o4 = hi there</pre>
</td></tr>
<tr><td><pre>i5 : x#"second" = "ho there"

o5 = ho there</pre>
</td></tr>
<tr><td><pre>i6 : scanKeys(x,print)
second
first</pre>
</td></tr>
<tr><td><pre>i7 : remove(x,"second")</pre>
</td></tr>
<tr><td><pre>i8 : scanKeys(x,print)
first</pre>
</td></tr>
<tr><td><pre>i9 : close x

o9 = 0</pre>
</td></tr>
<tr><td><pre>i10 : removeFile filename</pre>
</td></tr>
</table>
</div>
</div>
<div class="single"><h2>See also</h2>
<ul><li><span><a href="___Hash__Table.html" title="the class of all hash tables">HashTable</a> -- the class of all hash tables</span></li>
<li><span><a href="___String.html" title="the class of all strings">String</a> -- the class of all strings</span></li>
<li><span><a href="_remove__File.html" title="remove a file">removeFile</a> -- remove a file</span></li>
</ul>
</div>
<div class="waystouse"><h2>Functions and methods returning a database :</h2>
<ul><li><span>openDatabase(String), see <span><a href="_open__Database.html" title="open a database file">openDatabase</a> -- open a database file</span></span></li>
<li><span>openDatabaseOut(String), see <span><a href="_open__Database__Out.html" title="open a database file for writing">openDatabaseOut</a> -- open a database file for writing</span></span></li>
</ul>
<h2>Methods that use a database :</h2>
<ul><li><span><a href="___Database_sp_sh_sp__String.html" title="get value from database">Database # String</a> -- get value from database</span></li>
<li><span><a href="___Database_sp_sh_qu_sp__String.html" title="check for value in database">Database #? String</a> -- check for value in database</span></li>
<li><span>isOpen(Database), see <span><a href="_is__Open.html" title="whether a file or database is open">isOpen</a> -- whether a file or database is open</span></span></li>
<li><span>Manipulator Database, see <span><a href="___Manipulator.html" title="the class of all file manipulators">Manipulator</a> -- the class of all file manipulators</span></span></li>
<li><span>scanKeys(Database,Function), see <span><a href="_scan__Keys.html" title="apply a function to each key in a hash table or database">scanKeys</a> -- apply a function to each key in a hash table or database</span></span></li>
</ul>
</div>
<div class="waystouse"><h2>For the programmer</h2>
<p>The object <a href="___Database.html" title="the class of all database files">Database</a> is <span>a <a href="___Type.html">type</a></span>, with ancestor class <a href="___Thing.html" title="the class of all things">Thing</a>.</p>
</div>
</div>
</body>
</html>