You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

923 lines
30 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>util - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../../../../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../../../../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package util</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "github.com/syndtr/goleveldb/leveldb/util"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. </dl>
  58. </div>
  59. <!-- The package's Name is printed as title by the top-level template -->
  60. <div id="pkg-overview" class="toggleVisible">
  61. <div class="collapsed">
  62. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  63. </div>
  64. <div class="expanded">
  65. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  66. <p>
  67. Package util provides utilities used throughout leveldb.
  68. </p>
  69. </div>
  70. </div>
  71. <div id="pkg-index" class="toggleVisible">
  72. <div class="collapsed">
  73. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  74. </div>
  75. <div class="expanded">
  76. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  77. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  78. <div id="manual-nav">
  79. <dl>
  80. <dd><a href="index.html#pkg-constants">Constants</a></dd>
  81. <dd><a href="index.html#pkg-variables">Variables</a></dd>
  82. <dd><a href="index.html#Hash">func Hash(data []byte, seed uint32) uint32</a></dd>
  83. <dd><a href="index.html#BasicReleaser">type BasicReleaser</a></dd>
  84. <dd>&nbsp; &nbsp; <a href="index.html#BasicReleaser.Release">func (r *BasicReleaser) Release()</a></dd>
  85. <dd>&nbsp; &nbsp; <a href="index.html#BasicReleaser.Released">func (r *BasicReleaser) Released() bool</a></dd>
  86. <dd>&nbsp; &nbsp; <a href="index.html#BasicReleaser.SetReleaser">func (r *BasicReleaser) SetReleaser(releaser Releaser)</a></dd>
  87. <dd><a href="index.html#Buffer">type Buffer</a></dd>
  88. <dd>&nbsp; &nbsp; <a href="index.html#NewBuffer">func NewBuffer(buf []byte) *Buffer</a></dd>
  89. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.Alloc">func (b *Buffer) Alloc(n int) []byte</a></dd>
  90. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.Bytes">func (b *Buffer) Bytes() []byte</a></dd>
  91. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.Grow">func (b *Buffer) Grow(n int)</a></dd>
  92. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.Len">func (b *Buffer) Len() int</a></dd>
  93. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.Next">func (b *Buffer) Next(n int) []byte</a></dd>
  94. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.Read">func (b *Buffer) Read(p []byte) (n int, err error)</a></dd>
  95. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.ReadByte">func (b *Buffer) ReadByte() (c byte, err error)</a></dd>
  96. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.ReadBytes">func (b *Buffer) ReadBytes(delim byte) (line []byte, err error)</a></dd>
  97. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.ReadFrom">func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error)</a></dd>
  98. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.Reset">func (b *Buffer) Reset()</a></dd>
  99. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.String">func (b *Buffer) String() string</a></dd>
  100. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.Truncate">func (b *Buffer) Truncate(n int)</a></dd>
  101. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.Write">func (b *Buffer) Write(p []byte) (n int, err error)</a></dd>
  102. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.WriteByte">func (b *Buffer) WriteByte(c byte) error</a></dd>
  103. <dd>&nbsp; &nbsp; <a href="index.html#Buffer.WriteTo">func (b *Buffer) WriteTo(w io.Writer) (n int64, err error)</a></dd>
  104. <dd><a href="index.html#BufferPool">type BufferPool</a></dd>
  105. <dd>&nbsp; &nbsp; <a href="index.html#NewBufferPool">func NewBufferPool(baseline int) *BufferPool</a></dd>
  106. <dd>&nbsp; &nbsp; <a href="index.html#BufferPool.Close">func (p *BufferPool) Close()</a></dd>
  107. <dd>&nbsp; &nbsp; <a href="index.html#BufferPool.Get">func (p *BufferPool) Get(n int) []byte</a></dd>
  108. <dd>&nbsp; &nbsp; <a href="index.html#BufferPool.Put">func (p *BufferPool) Put(b []byte)</a></dd>
  109. <dd>&nbsp; &nbsp; <a href="index.html#BufferPool.String">func (p *BufferPool) String() string</a></dd>
  110. <dd><a href="index.html#CRC">type CRC</a></dd>
  111. <dd>&nbsp; &nbsp; <a href="index.html#NewCRC">func NewCRC(b []byte) CRC</a></dd>
  112. <dd>&nbsp; &nbsp; <a href="index.html#CRC.Update">func (c CRC) Update(b []byte) CRC</a></dd>
  113. <dd>&nbsp; &nbsp; <a href="index.html#CRC.Value">func (c CRC) Value() uint32</a></dd>
  114. <dd><a href="index.html#NoopReleaser">type NoopReleaser</a></dd>
  115. <dd>&nbsp; &nbsp; <a href="index.html#NoopReleaser.Release">func (NoopReleaser) Release()</a></dd>
  116. <dd><a href="index.html#Range">type Range</a></dd>
  117. <dd>&nbsp; &nbsp; <a href="index.html#BytesPrefix">func BytesPrefix(prefix []byte) *Range</a></dd>
  118. <dd><a href="index.html#ReleaseSetter">type ReleaseSetter</a></dd>
  119. <dd><a href="index.html#Releaser">type Releaser</a></dd>
  120. </dl>
  121. </div><!-- #manual-nav -->
  122. <h4>Package files</h4>
  123. <p>
  124. <span style="font-size:90%">
  125. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go">buffer.go</a>
  126. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go">buffer_pool.go</a>
  127. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/crc32.go">crc32.go</a>
  128. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/hash.go">hash.go</a>
  129. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/range.go">range.go</a>
  130. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/util.go">util.go</a>
  131. </span>
  132. </p>
  133. </div><!-- .expanded -->
  134. </div><!-- #pkg-index -->
  135. <div id="pkg-callgraph" class="toggle" style="display: none">
  136. <div class="collapsed">
  137. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  138. </div> <!-- .expanded -->
  139. <div class="expanded">
  140. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  141. <p>
  142. In the call graph viewer below, each node
  143. is a function belonging to this package
  144. and its children are the functions it
  145. calls&mdash;perhaps dynamically.
  146. </p>
  147. <p>
  148. The root nodes are the entry points of the
  149. package: functions that may be called from
  150. outside the package.
  151. There may be non-exported or anonymous
  152. functions among them if they are called
  153. dynamically from another package.
  154. </p>
  155. <p>
  156. Click a node to visit that function's source code.
  157. From there you can visit its callers by
  158. clicking its declaring <code>func</code>
  159. token.
  160. </p>
  161. <p>
  162. Functions may be omitted if they were
  163. determined to be unreachable in the
  164. particular programs or tests that were
  165. analyzed.
  166. </p>
  167. <!-- Zero means show all package entry points. -->
  168. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  169. </div>
  170. </div> <!-- #pkg-callgraph -->
  171. <h2 id="pkg-constants">Constants</h2>
  172. <pre>const <span id="MinRead">MinRead</span> = 512</pre>
  173. <p>
  174. MinRead is the minimum slice size passed to a Read call by
  175. Buffer.ReadFrom. As long as the Buffer has at least MinRead bytes beyond
  176. what is required to hold the contents of r, ReadFrom will not grow the
  177. underlying buffer.
  178. </p>
  179. <h2 id="pkg-variables">Variables</h2>
  180. <pre>var (
  181. <span id="ErrReleased">ErrReleased</span> = <a href="../../../../../errors/index.html">errors</a>.<a href="../../../../../errors/index.html#New">New</a>(&#34;leveldb: resource already relesed&#34;)
  182. <span id="ErrHasReleaser">ErrHasReleaser</span> = <a href="../../../../../errors/index.html">errors</a>.<a href="../../../../../errors/index.html#New">New</a>(&#34;leveldb: releaser already defined&#34;)
  183. )</pre>
  184. <h2 id="Hash">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/hash.go?s=279:321#L4">Hash</a></h2>
  185. <pre>func Hash(data []<a href="../../../../../builtin/index.html#byte">byte</a>, seed <a href="../../../../../builtin/index.html#uint32">uint32</a>) <a href="../../../../../builtin/index.html#uint32">uint32</a></pre>
  186. <p>
  187. Hash return hash of the given data.
  188. </p>
  189. <h2 id="BasicReleaser">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/util.go?s=1249:1312#L29">BasicReleaser</a></h2>
  190. <pre>type BasicReleaser struct {
  191. <span class="comment">// contains filtered or unexported fields</span>
  192. }</pre>
  193. <p>
  194. BasicReleaser provides basic implementation of Releaser and ReleaseSetter.
  195. </p>
  196. <h3 id="BasicReleaser.Release">func (*BasicReleaser) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/util.go?s=1477:1510#L40">Release</a></h3>
  197. <pre>func (r *<a href="index.html#BasicReleaser">BasicReleaser</a>) Release()</pre>
  198. <p>
  199. Release implements Releaser.Release.
  200. </p>
  201. <h3 id="BasicReleaser.Released">func (*BasicReleaser) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/util.go?s=1373:1412#L35">Released</a></h3>
  202. <pre>func (r *<a href="index.html#BasicReleaser">BasicReleaser</a>) Released() <a href="../../../../../builtin/index.html#bool">bool</a></pre>
  203. <p>
  204. Released returns whether Release method already called.
  205. </p>
  206. <h3 id="BasicReleaser.SetReleaser">func (*BasicReleaser) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/util.go?s=1683:1737#L51">SetReleaser</a></h3>
  207. <pre>func (r *<a href="index.html#BasicReleaser">BasicReleaser</a>) SetReleaser(releaser <a href="index.html#Releaser">Releaser</a>)</pre>
  208. <p>
  209. SetReleaser implements ReleaseSetter.SetReleaser.
  210. </p>
  211. <h2 id="Buffer">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=433:685#L7">Buffer</a></h2>
  212. <pre>type Buffer struct {
  213. <span class="comment">// contains filtered or unexported fields</span>
  214. }</pre>
  215. <p>
  216. A Buffer is a variable-sized buffer of bytes with Read and Write methods.
  217. The zero value for Buffer is an empty buffer ready to use.
  218. </p>
  219. <h3 id="NewBuffer">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=9217:9251#L283">NewBuffer</a></h3>
  220. <pre>func NewBuffer(buf []<a href="../../../../../builtin/index.html#byte">byte</a>) *<a href="index.html#Buffer">Buffer</a></pre>
  221. <p>
  222. NewBuffer creates and initializes a new Buffer using buf as its initial
  223. contents. It is intended to prepare a Buffer to read existing data. It
  224. can also be used to size the internal buffer for writing. To do that,
  225. buf should have the desired capacity but a length of zero.
  226. </p>
  227. <p>
  228. In most cases, new(Buffer) (or just declaring a Buffer variable) is
  229. sufficient to initialize a Buffer.
  230. </p>
  231. <h3 id="Buffer.Alloc">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=3071:3107#L85">Alloc</a></h3>
  232. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) Alloc(n <a href="../../../../../builtin/index.html#int">int</a>) []<a href="../../../../../builtin/index.html#byte">byte</a></pre>
  233. <p>
  234. Alloc allocs n bytes of slice from the buffer, growing the buffer as
  235. needed. If n is negative, Alloc will panic.
  236. If the buffer can&#39;t grow it will panic with bytes.ErrTooLarge.
  237. </p>
  238. <h3 id="Buffer.Bytes">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=961:992#L17">Bytes</a></h3>
  239. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) Bytes() []<a href="../../../../../builtin/index.html#byte">byte</a></pre>
  240. <p>
  241. Bytes returns a slice of the contents of the unread portion of the buffer;
  242. len(b.Bytes()) == b.Len(). If the caller changes the contents of the
  243. returned slice, the contents of the buffer will change provided there
  244. are no intervening method calls on the Buffer.
  245. </p>
  246. <h3 id="Buffer.Grow">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=3505:3533#L98">Grow</a></h3>
  247. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) Grow(n <a href="../../../../../builtin/index.html#int">int</a>)</pre>
  248. <p>
  249. Grow grows the buffer&#39;s capacity, if necessary, to guarantee space for
  250. another n bytes. After Grow(n), at least n bytes can be written to the
  251. buffer without another allocation.
  252. If n is negative, Grow will panic.
  253. If the buffer can&#39;t grow it will panic with bytes.ErrTooLarge.
  254. </p>
  255. <h3 id="Buffer.Len">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=1400:1426#L31">Len</a></h3>
  256. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) Len() <a href="../../../../../builtin/index.html#int">int</a></pre>
  257. <p>
  258. Len returns the number of bytes of the unread portion of the buffer;
  259. b.Len() == len(b.Bytes()).
  260. </p>
  261. <h3 id="Buffer.Next">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=7427:7462#L226">Next</a></h3>
  262. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) Next(n <a href="../../../../../builtin/index.html#int">int</a>) []<a href="../../../../../builtin/index.html#byte">byte</a></pre>
  263. <p>
  264. Next returns a slice containing the next n bytes from the buffer,
  265. advancing the buffer as if the bytes had been returned by Read.
  266. If there are fewer than n bytes in the buffer, Next returns the entire buffer.
  267. The slice is only valid until the next call to a read or write method.
  268. </p>
  269. <h3 id="Buffer.Read">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=6888:6938#L208">Read</a></h3>
  270. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) Read(p []<a href="../../../../../builtin/index.html#byte">byte</a>) (n <a href="../../../../../builtin/index.html#int">int</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  271. <p>
  272. Read reads the next len(p) bytes from the buffer or until the buffer
  273. is drained. The return value n is the number of bytes read. If the
  274. buffer has no data to return, err is io.EOF (unless len(p) is zero);
  275. otherwise it is nil.
  276. </p>
  277. <h3 id="Buffer.ReadByte">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=7676:7723#L238">ReadByte</a></h3>
  278. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) ReadByte() (c <a href="../../../../../builtin/index.html#byte">byte</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  279. <p>
  280. ReadByte reads and returns the next byte from the buffer.
  281. If no byte is available, it returns error io.EOF.
  282. </p>
  283. <h3 id="Buffer.ReadBytes">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=8263:8326#L255">ReadBytes</a></h3>
  284. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) ReadBytes(delim <a href="../../../../../builtin/index.html#byte">byte</a>) (line []<a href="../../../../../builtin/index.html#byte">byte</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  285. <p>
  286. ReadBytes reads until the first occurrence of delim in the input,
  287. returning a slice containing the data up to and including the delimiter.
  288. If ReadBytes encounters an error before finding a delimiter,
  289. it returns the data read before the error and the error itself (often io.EOF).
  290. ReadBytes returns err != nil if and only if the returned data does not end in
  291. delim.
  292. </p>
  293. <h3 id="Buffer.ReadFrom">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=4530:4589#L124">ReadFrom</a></h3>
  294. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) ReadFrom(r <a href="../../../../../io/index.html">io</a>.<a href="../../../../../io/index.html#Reader">Reader</a>) (n <a href="../../../../../builtin/index.html#int64">int64</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  295. <p>
  296. ReadFrom reads data from r until EOF and appends it to the buffer, growing
  297. the buffer as needed. The return value n is the number of bytes read. Any
  298. error except io.EOF encountered during the read is also returned. If the
  299. buffer becomes too large, ReadFrom will panic with bytes.ErrTooLarge.
  300. </p>
  301. <h3 id="Buffer.Reset">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=1907:1931#L48">Reset</a></h3>
  302. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) Reset()</pre>
  303. <p>
  304. Reset resets the buffer so it has no content.
  305. b.Reset() is the same as b.Truncate(0).
  306. </p>
  307. <h3 id="Buffer.String">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=1155:1187#L21">String</a></h3>
  308. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) String() <a href="../../../../../builtin/index.html#string">string</a></pre>
  309. <p>
  310. String returns the contents of the unread portion of the buffer
  311. as a string. If the Buffer is a nil pointer, it returns &#34;&lt;nil&gt;&#34;.
  312. </p>
  313. <h3 id="Buffer.Truncate">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=1601:1633#L35">Truncate</a></h3>
  314. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) Truncate(n <a href="../../../../../builtin/index.html#int">int</a>)</pre>
  315. <p>
  316. Truncate discards all but the first n unread bytes from the buffer.
  317. It panics if n is negative or greater than the length of the buffer.
  318. </p>
  319. <h3 id="Buffer.Write">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=3860:3911#L109">Write</a></h3>
  320. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) Write(p []<a href="../../../../../builtin/index.html#byte">byte</a>) (n <a href="../../../../../builtin/index.html#int">int</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  321. <p>
  322. Write appends the contents of p to the buffer, growing the buffer as
  323. needed. The return value n is the length of p; err is always nil. If the
  324. buffer becomes too large, Write will panic with bytes.ErrTooLarge.
  325. </p>
  326. <h3 id="Buffer.WriteByte">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=6560:6600#L198">WriteByte</a></h3>
  327. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) WriteByte(c <a href="../../../../../builtin/index.html#byte">byte</a>) <a href="../../../../../builtin/index.html#error">error</a></pre>
  328. <p>
  329. WriteByte appends the byte c to the buffer, growing the buffer as needed.
  330. The returned error is always nil, but is included to match bufio.Writer&#39;s
  331. WriteByte. If the buffer becomes too large, WriteByte will panic with
  332. bytes.ErrTooLarge.
  333. </p>
  334. <h3 id="Buffer.WriteTo">func (*Buffer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer.go?s=5823:5881#L171">WriteTo</a></h3>
  335. <pre>func (b *<a href="index.html#Buffer">Buffer</a>) WriteTo(w <a href="../../../../../io/index.html">io</a>.<a href="../../../../../io/index.html#Writer">Writer</a>) (n <a href="../../../../../builtin/index.html#int64">int64</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  336. <p>
  337. WriteTo writes data to w until the buffer is drained or an error occurs.
  338. The return value n is the number of bytes written; it always fits into an
  339. int, but it is int64 to match the io.WriterTo interface. Any error
  340. encountered during the write is also returned.
  341. </p>
  342. <h2 id="BufferPool">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go?s=340:658#L12">BufferPool</a></h2>
  343. <pre>type BufferPool struct {
  344. <span class="comment">// contains filtered or unexported fields</span>
  345. }</pre>
  346. <p>
  347. BufferPool is a &#39;buffer pool&#39;.
  348. </p>
  349. <h3 id="NewBufferPool">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go?s=3989:4033#L215">NewBufferPool</a></h3>
  350. <pre>func NewBufferPool(baseline <a href="../../../../../builtin/index.html#int">int</a>) *<a href="index.html#BufferPool">BufferPool</a></pre>
  351. <p>
  352. NewBufferPool creates a new initialized &#39;buffer pool&#39;.
  353. </p>
  354. <h3 id="BufferPool.Close">func (*BufferPool) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go?s=3170:3198#L170">Close</a></h3>
  355. <pre>func (p *<a href="index.html#BufferPool">BufferPool</a>) Close()</pre>
  356. <h3 id="BufferPool.Get">func (*BufferPool) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go?s=900:938#L46">Get</a></h3>
  357. <pre>func (p *<a href="index.html#BufferPool">BufferPool</a>) Get(n <a href="../../../../../builtin/index.html#int">int</a>) []<a href="../../../../../builtin/index.html#byte">byte</a></pre>
  358. <p>
  359. Get returns buffer with length of n.
  360. </p>
  361. <h3 id="BufferPool.Put">func (*BufferPool) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go?s=2931:2965#L148">Put</a></h3>
  362. <pre>func (p *<a href="index.html#BufferPool">BufferPool</a>) Put(b []<a href="../../../../../builtin/index.html#byte">byte</a>)</pre>
  363. <p>
  364. Put adds given buffer to the pool.
  365. </p>
  366. <h3 id="BufferPool.String">func (*BufferPool) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go?s=3322:3358#L183">String</a></h3>
  367. <pre>func (p *<a href="index.html#BufferPool">BufferPool</a>) String() <a href="../../../../../builtin/index.html#string">string</a></pre>
  368. <h2 id="CRC">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/crc32.go?s=326:341#L5">CRC</a></h2>
  369. <pre>type CRC <a href="../../../../../builtin/index.html#uint32">uint32</a></pre>
  370. <p>
  371. CRC is a CRC-32 checksum computed using Castagnoli&#39;s polynomial.
  372. </p>
  373. <h3 id="NewCRC">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/crc32.go?s=397:422#L8">NewCRC</a></h3>
  374. <pre>func NewCRC(b []<a href="../../../../../builtin/index.html#byte">byte</a>) <a href="index.html#CRC">CRC</a></pre>
  375. <p>
  376. NewCRC creates a new crc based on the given bytes.
  377. </p>
  378. <h3 id="CRC.Update">func (CRC) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/crc32.go?s=501:534#L13">Update</a></h3>
  379. <pre>func (c <a href="index.html#CRC">CRC</a>) Update(b []<a href="../../../../../builtin/index.html#byte">byte</a>) <a href="index.html#CRC">CRC</a></pre>
  380. <p>
  381. Update updates the crc with the given bytes.
  382. </p>
  383. <h3 id="CRC.Value">func (CRC) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/crc32.go?s=618:645#L18">Value</a></h3>
  384. <pre>func (c <a href="index.html#CRC">CRC</a>) Value() <a href="../../../../../builtin/index.html#uint32">uint32</a></pre>
  385. <p>
  386. Value returns a masked crc.
  387. </p>
  388. <h2 id="NoopReleaser">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/util.go?s=1877:1903#L61">NoopReleaser</a></h2>
  389. <pre>type NoopReleaser struct{}</pre>
  390. <h3 id="NoopReleaser.Release">func (NoopReleaser) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/util.go?s=1905:1934#L63">Release</a></h3>
  391. <pre>func (<a href="index.html#NoopReleaser">NoopReleaser</a>) Release()</pre>
  392. <h2 id="Range">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/range.go?s=234:388#L1">Range</a></h2>
  393. <pre>type Range struct {
  394. <span class="comment">// Start of the key range, include in the range.</span>
  395. Start []<a href="../../../../../builtin/index.html#byte">byte</a>
  396. <span class="comment">// Limit of the key range, not include in the range.</span>
  397. Limit []<a href="../../../../../builtin/index.html#byte">byte</a>
  398. }</pre>
  399. <p>
  400. Range is a key range.
  401. </p>
  402. <h3 id="BytesPrefix">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/range.go?s=513:551#L10">BytesPrefix</a></h3>
  403. <pre>func BytesPrefix(prefix []<a href="../../../../../builtin/index.html#byte">byte</a>) *<a href="index.html#Range">Range</a></pre>
  404. <p>
  405. BytesPrefix returns key range that satisfy the given prefix.
  406. This only applicable for the standard &#39;bytes comparer&#39;.
  407. </p>
  408. <h2 id="ReleaseSetter">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/util.go?s=745:1169#L17">ReleaseSetter</a></h2>
  409. <pre>type ReleaseSetter interface {
  410. <span class="comment">// SetReleaser associates the given releaser to the resources. The</span>
  411. <span class="comment">// releaser will be called once coresponding resources released.</span>
  412. <span class="comment">// Calling SetReleaser with nil will clear the releaser.</span>
  413. <span class="comment">//</span>
  414. <span class="comment">// This will panic if a releaser already present or coresponding</span>
  415. <span class="comment">// resource is already released. Releaser should be cleared first</span>
  416. <span class="comment">// before assigned a new one.</span>
  417. SetReleaser(releaser <a href="index.html#Releaser">Releaser</a>)
  418. }</pre>
  419. <p>
  420. ReleaseSetter is the interface that wraps the basic SetReleaser method.
  421. </p>
  422. <h2 id="Releaser">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/util/util.go?s=498:668#L10">Releaser</a></h2>
  423. <pre>type Releaser interface {
  424. <span class="comment">// Release releases associated resources. Release should always success</span>
  425. <span class="comment">// and can be called multipe times without causing error.</span>
  426. Release()
  427. }</pre>
  428. <p>
  429. Releaser is the interface that wraps the basic Release method.
  430. </p>
  431. <div id="footer">
  432. Build version go1.6.<br>
  433. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  434. the content of this page is licensed under the
  435. Creative Commons Attribution 3.0 License,
  436. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  437. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  438. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  439. </div>
  440. </div><!-- .container -->
  441. </div><!-- #page -->
  442. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  443. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.js"></script>
  444. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.treeview.js"></script>
  445. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.treeview.edit.js"></script>
  446. <script type="text/javascript" src="../../../../../../lib/godoc/godocs.js"></script>
  447. </body>
  448. </html>