Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / html / python / lib / dbhash-objects.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="prev" href="module-dbhash.html" />
13<link rel="parent" href="module-dbhash.html" />
14<link rel="next" href="module-whichdb.html" />
15<meta name='aesop' content='information' />
16<title>7.11.1 Database Objects </title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="7.11 dbhash "
24 href="module-dbhash.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="7.11 dbhash "
27 href="module-dbhash.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="7.12 whichdb "
30 href="module-whichdb.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Python Library Reference</td>
33<td class='online-navigation'><a rel="contents" title="Table of Contents"
34 href="contents.html"><img src='../icons/contents.png'
35 border='0' height='32' alt='Contents' width='32' /></A></td>
36<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
37 border='0' height='32' alt='Module Index' width='32' /></a></td>
38<td class='online-navigation'><a rel="index" title="Index"
39 href="genindex.html"><img src='../icons/index.png'
40 border='0' height='32' alt='Index' width='32' /></A></td>
41</tr></table>
42<div class='online-navigation'>
43<b class="navlabel">Previous:</b>
44<a class="sectref" rel="prev" href="module-dbhash.html">7.11 dbhash </A>
45<b class="navlabel">Up:</b>
46<a class="sectref" rel="parent" href="module-dbhash.html">7.11 dbhash </A>
47<b class="navlabel">Next:</b>
48<a class="sectref" rel="next" href="module-whichdb.html">7.12 whichdb </A>
49</div>
50<hr /></div>
51</DIV>
52<!--End of Navigation Panel-->
53
54<H2><A NAME="SECTION0091110000000000000000"></A><A NAME="dbhash-objects"></A>
55<BR>
567.11.1 Database Objects
57</H2>
58
59<P>
60The database objects returned by <tt class="function">open()</tt> provide the methods
61common to all the DBM-style databases and mapping objects. The following
62methods are available in addition to the standard methods.
63
64<P>
65<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
66 <td><nobr><b><tt id='l2h-2789' xml:id='l2h-2789' class="method">first</tt></b>(</nobr></td>
67 <td><var></var>)</td></tr></table></dt>
68<dd>
69 It's possible to loop over every key/value pair in the database using
70 this method and the <tt class="method">next()</tt> method. The traversal is ordered by
71 the databases internal hash values, and won't be sorted by the key
72 values. This method returns the starting key.
73</dl>
74
75<P>
76<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
77 <td><nobr><b><tt id='l2h-2790' xml:id='l2h-2790' class="method">last</tt></b>(</nobr></td>
78 <td><var></var>)</td></tr></table></dt>
79<dd>
80 Return the last key/value pair in a database traversal. This may be used to
81 begin a reverse-order traversal; see <tt class="method">previous()</tt>.
82</dl>
83
84<P>
85<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
86 <td><nobr><b><tt id='l2h-2791' xml:id='l2h-2791' class="method">next</tt></b>(</nobr></td>
87 <td><var></var>)</td></tr></table></dt>
88<dd>
89 Returns the key next key/value pair in a database traversal. The
90 following code prints every key in the database <code>db</code>, without
91 having to create a list in memory that contains them all:
92
93<P>
94<div class="verbatim"><pre>
95print db.first()
96for i in xrange(1, len(db)):
97 print db.next()
98</pre></div>
99</dl>
100
101<P>
102<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
103 <td><nobr><b><tt id='l2h-2792' xml:id='l2h-2792' class="method">previous</tt></b>(</nobr></td>
104 <td><var></var>)</td></tr></table></dt>
105<dd>
106 Returns the previous key/value pair in a forward-traversal of the database.
107 In conjunction with <tt class="method">last()</tt>, this may be used to implement
108 a reverse-order traversal.
109</dl>
110
111<P>
112<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
113 <td><nobr><b><tt id='l2h-2793' xml:id='l2h-2793' class="method">sync</tt></b>(</nobr></td>
114 <td><var></var>)</td></tr></table></dt>
115<dd>
116 This method forces any unwritten data to be written to the disk.
117</dl>
118
119<DIV CLASS="navigation">
120<div class='online-navigation'>
121<p></p><hr />
122<table align="center" width="100%" cellpadding="0" cellspacing="2">
123<tr>
124<td class='online-navigation'><a rel="prev" title="7.11 dbhash "
125 href="module-dbhash.html"><img src='../icons/previous.png'
126 border='0' height='32' alt='Previous Page' width='32' /></A></td>
127<td class='online-navigation'><a rel="parent" title="7.11 dbhash "
128 href="module-dbhash.html"><img src='../icons/up.png'
129 border='0' height='32' alt='Up One Level' width='32' /></A></td>
130<td class='online-navigation'><a rel="next" title="7.12 whichdb "
131 href="module-whichdb.html"><img src='../icons/next.png'
132 border='0' height='32' alt='Next Page' width='32' /></A></td>
133<td align="center" width="100%">Python Library Reference</td>
134<td class='online-navigation'><a rel="contents" title="Table of Contents"
135 href="contents.html"><img src='../icons/contents.png'
136 border='0' height='32' alt='Contents' width='32' /></A></td>
137<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
138 border='0' height='32' alt='Module Index' width='32' /></a></td>
139<td class='online-navigation'><a rel="index" title="Index"
140 href="genindex.html"><img src='../icons/index.png'
141 border='0' height='32' alt='Index' width='32' /></A></td>
142</tr></table>
143<div class='online-navigation'>
144<b class="navlabel">Previous:</b>
145<a class="sectref" rel="prev" href="module-dbhash.html">7.11 dbhash </A>
146<b class="navlabel">Up:</b>
147<a class="sectref" rel="parent" href="module-dbhash.html">7.11 dbhash </A>
148<b class="navlabel">Next:</b>
149<a class="sectref" rel="next" href="module-whichdb.html">7.12 whichdb </A>
150</div>
151</div>
152<hr />
153<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
154</DIV>
155<!--End of Navigation Panel-->
156<ADDRESS>
157See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
158</ADDRESS>
159</BODY>
160</HTML>