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.

781 lines
24 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>btree - 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 btree</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/google/btree"</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. <dd><a href="index.html#pkg-examples" class="examplesLink">Examples</a></dd>
  58. </dl>
  59. </div>
  60. <!-- The package's Name is printed as title by the top-level template -->
  61. <div id="pkg-overview" class="toggleVisible">
  62. <div class="collapsed">
  63. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  64. </div>
  65. <div class="expanded">
  66. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  67. <p>
  68. Package btree implements in-memory B-Trees of arbitrary degree.
  69. </p>
  70. <p>
  71. btree implements an in-memory B-Tree for use as an ordered data structure.
  72. It is not meant for persistent storage solutions.
  73. </p>
  74. <p>
  75. It has a flatter structure than an equivalent red-black or other binary tree,
  76. which in some cases yields better memory usage and/or performance.
  77. See some discussion on the matter here:
  78. </p>
  79. <pre><a href="http://google-opensource.blogspot.com/2013/01/c-containers-that-save-memory-and-time.html">http://google-opensource.blogspot.com/2013/01/c-containers-that-save-memory-and-time.html</a>
  80. </pre>
  81. <p>
  82. Note, though, that this project is in no way related to the C++ B-Tree
  83. implementation written about there.
  84. </p>
  85. <p>
  86. Within this tree, each node contains a slice of items and a (possibly nil)
  87. slice of children. For basic numeric values or raw structs, this can cause
  88. efficiency differences when compared to equivalent C++ template code that
  89. stores values in arrays within the node:
  90. </p>
  91. <pre>* Due to the overhead of storing values as interfaces (each
  92. value needs to be stored as the value itself, then 2 words for the
  93. interface pointing to that value and its type), resulting in higher
  94. memory use.
  95. * Since interfaces can point to values anywhere in memory, values are
  96. most likely not stored in contiguous blocks, resulting in a higher
  97. number of cache misses.
  98. </pre>
  99. <p>
  100. These issues don&#39;t tend to matter, though, when working with strings or other
  101. heap-allocated structures, since C++-equivalent structures also must store
  102. pointers and also distribute their values across the heap.
  103. </p>
  104. <p>
  105. This implementation is designed to be a drop-in replacement to gollrb.LLRB
  106. trees, (<a href="http://github.com/petar/gollrb">http://github.com/petar/gollrb</a>), an excellent and probably the most
  107. widely used ordered tree implementation in the Go ecosystem currently.
  108. Its functions, therefore, exactly mirror those of
  109. llrb.LLRB where possible. Unlike gollrb, though, we currently don&#39;t
  110. support storing multiple equivalent values.
  111. </p>
  112. </div>
  113. </div>
  114. <div id="pkg-index" class="toggleVisible">
  115. <div class="collapsed">
  116. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  117. </div>
  118. <div class="expanded">
  119. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  120. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  121. <div id="manual-nav">
  122. <dl>
  123. <dd><a href="index.html#pkg-constants">Constants</a></dd>
  124. <dd><a href="index.html#BTree">type BTree</a></dd>
  125. <dd>&nbsp; &nbsp; <a href="index.html#New">func New(degree int) *BTree</a></dd>
  126. <dd>&nbsp; &nbsp; <a href="index.html#NewWithFreeList">func NewWithFreeList(degree int, f *FreeList) *BTree</a></dd>
  127. <dd>&nbsp; &nbsp; <a href="index.html#BTree.Ascend">func (t *BTree) Ascend(iterator ItemIterator)</a></dd>
  128. <dd>&nbsp; &nbsp; <a href="index.html#BTree.AscendGreaterOrEqual">func (t *BTree) AscendGreaterOrEqual(pivot Item, iterator ItemIterator)</a></dd>
  129. <dd>&nbsp; &nbsp; <a href="index.html#BTree.AscendLessThan">func (t *BTree) AscendLessThan(pivot Item, iterator ItemIterator)</a></dd>
  130. <dd>&nbsp; &nbsp; <a href="index.html#BTree.AscendRange">func (t *BTree) AscendRange(greaterOrEqual, lessThan Item, iterator ItemIterator)</a></dd>
  131. <dd>&nbsp; &nbsp; <a href="index.html#BTree.Delete">func (t *BTree) Delete(item Item) Item</a></dd>
  132. <dd>&nbsp; &nbsp; <a href="index.html#BTree.DeleteMax">func (t *BTree) DeleteMax() Item</a></dd>
  133. <dd>&nbsp; &nbsp; <a href="index.html#BTree.DeleteMin">func (t *BTree) DeleteMin() Item</a></dd>
  134. <dd>&nbsp; &nbsp; <a href="index.html#BTree.Descend">func (t *BTree) Descend(iterator ItemIterator)</a></dd>
  135. <dd>&nbsp; &nbsp; <a href="index.html#BTree.DescendGreaterThan">func (t *BTree) DescendGreaterThan(pivot Item, iterator ItemIterator)</a></dd>
  136. <dd>&nbsp; &nbsp; <a href="index.html#BTree.DescendLessOrEqual">func (t *BTree) DescendLessOrEqual(pivot Item, iterator ItemIterator)</a></dd>
  137. <dd>&nbsp; &nbsp; <a href="index.html#BTree.DescendRange">func (t *BTree) DescendRange(lessOrEqual, greaterThan Item, iterator ItemIterator)</a></dd>
  138. <dd>&nbsp; &nbsp; <a href="index.html#BTree.Get">func (t *BTree) Get(key Item) Item</a></dd>
  139. <dd>&nbsp; &nbsp; <a href="index.html#BTree.Has">func (t *BTree) Has(key Item) bool</a></dd>
  140. <dd>&nbsp; &nbsp; <a href="index.html#BTree.Len">func (t *BTree) Len() int</a></dd>
  141. <dd>&nbsp; &nbsp; <a href="index.html#BTree.Max">func (t *BTree) Max() Item</a></dd>
  142. <dd>&nbsp; &nbsp; <a href="index.html#BTree.Min">func (t *BTree) Min() Item</a></dd>
  143. <dd>&nbsp; &nbsp; <a href="index.html#BTree.ReplaceOrInsert">func (t *BTree) ReplaceOrInsert(item Item) Item</a></dd>
  144. <dd><a href="index.html#FreeList">type FreeList</a></dd>
  145. <dd>&nbsp; &nbsp; <a href="index.html#NewFreeList">func NewFreeList(size int) *FreeList</a></dd>
  146. <dd><a href="index.html#Int">type Int</a></dd>
  147. <dd>&nbsp; &nbsp; <a href="index.html#Int.Less">func (a Int) Less(b Item) bool</a></dd>
  148. <dd><a href="index.html#Item">type Item</a></dd>
  149. <dd><a href="index.html#ItemIterator">type ItemIterator</a></dd>
  150. </dl>
  151. </div><!-- #manual-nav -->
  152. <div id="pkg-examples">
  153. <h4>Examples</h4>
  154. <dl>
  155. <dd><a class="exampleLink" href="index.html#example_BTree">BTree</a></dd>
  156. </dl>
  157. </div>
  158. <h4>Package files</h4>
  159. <p>
  160. <span style="font-size:90%">
  161. <a href="http://localhost:6060/src/github.com/google/btree/btree.go">btree.go</a>
  162. </span>
  163. </p>
  164. </div><!-- .expanded -->
  165. </div><!-- #pkg-index -->
  166. <div id="pkg-callgraph" class="toggle" style="display: none">
  167. <div class="collapsed">
  168. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  169. </div> <!-- .expanded -->
  170. <div class="expanded">
  171. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  172. <p>
  173. In the call graph viewer below, each node
  174. is a function belonging to this package
  175. and its children are the functions it
  176. calls&mdash;perhaps dynamically.
  177. </p>
  178. <p>
  179. The root nodes are the entry points of the
  180. package: functions that may be called from
  181. outside the package.
  182. There may be non-exported or anonymous
  183. functions among them if they are called
  184. dynamically from another package.
  185. </p>
  186. <p>
  187. Click a node to visit that function's source code.
  188. From there you can visit its callers by
  189. clicking its declaring <code>func</code>
  190. token.
  191. </p>
  192. <p>
  193. Functions may be omitted if they were
  194. determined to be unreachable in the
  195. particular programs or tests that were
  196. analyzed.
  197. </p>
  198. <!-- Zero means show all package entry points. -->
  199. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  200. </div>
  201. </div> <!-- #pkg-callgraph -->
  202. <h2 id="pkg-constants">Constants</h2>
  203. <pre>const (
  204. <span id="DefaultFreeListSize">DefaultFreeListSize</span> = 32
  205. )</pre>
  206. <h2 id="BTree">type <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=15979:16064#L527">BTree</a></h2>
  207. <pre>type BTree struct {
  208. <span class="comment">// contains filtered or unexported fields</span>
  209. }</pre>
  210. <p>
  211. BTree is an implementation of a B-Tree.
  212. </p>
  213. <p>
  214. BTree stores Item instances in an ordered structure, allowing easy insertion,
  215. removal, and iteration.
  216. </p>
  217. <p>
  218. Write operations are not safe for concurrent mutation by multiple
  219. goroutines, but Read operations are.
  220. </p>
  221. <div id="example_BTree" class="toggle">
  222. <div class="collapsed">
  223. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  224. </div>
  225. <div class="expanded">
  226. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  227. <p>Code:</p>
  228. <pre class="code">tr := New(*btreeDegree)
  229. for i := Int(0); i &lt; 10; i++ {
  230. tr.ReplaceOrInsert(i)
  231. }
  232. fmt.Println(&#34;len: &#34;, tr.Len())
  233. fmt.Println(&#34;get3: &#34;, tr.Get(Int(3)))
  234. fmt.Println(&#34;get100: &#34;, tr.Get(Int(100)))
  235. fmt.Println(&#34;del4: &#34;, tr.Delete(Int(4)))
  236. fmt.Println(&#34;del100: &#34;, tr.Delete(Int(100)))
  237. fmt.Println(&#34;replace5: &#34;, tr.ReplaceOrInsert(Int(5)))
  238. fmt.Println(&#34;replace100:&#34;, tr.ReplaceOrInsert(Int(100)))
  239. fmt.Println(&#34;min: &#34;, tr.Min())
  240. fmt.Println(&#34;delmin: &#34;, tr.DeleteMin())
  241. fmt.Println(&#34;max: &#34;, tr.Max())
  242. fmt.Println(&#34;delmax: &#34;, tr.DeleteMax())
  243. fmt.Println(&#34;len: &#34;, tr.Len())
  244. <span class="comment"></pre>
  245. <p>Output:</p>
  246. <pre class="output">len: 10
  247. get3: 3
  248. get100: &lt;nil&gt;
  249. del4: 4
  250. del100: &lt;nil&gt;
  251. replace5: 5
  252. replace100: &lt;nil&gt;
  253. min: 0
  254. delmin: 0
  255. max: 100
  256. delmax: 100
  257. len: 8
  258. </pre>
  259. </div>
  260. </div>
  261. <h3 id="New">func <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=4217:4244#L106">New</a></h3>
  262. <pre>func New(degree <a href="../../../builtin/index.html#int">int</a>) *<a href="index.html#BTree">BTree</a></pre>
  263. <p>
  264. New creates a new B-Tree with the given degree.
  265. </p>
  266. <p>
  267. New(2), for example, will create a 2-3-4 tree (each node contains 1-3 items
  268. and 2-4 children).
  269. </p>
  270. <h3 id="NewWithFreeList">func <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=4392:4444#L111">NewWithFreeList</a></h3>
  271. <pre>func NewWithFreeList(degree <a href="../../../builtin/index.html#int">int</a>, f *<a href="index.html#FreeList">FreeList</a>) *<a href="index.html#BTree">BTree</a></pre>
  272. <p>
  273. NewWithFreeList creates a new B-Tree that uses the given node free list.
  274. </p>
  275. <h3 id="BTree.Ascend">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=19353:19398#L650">Ascend</a></h3>
  276. <pre>func (t *<a href="index.html#BTree">BTree</a>) Ascend(iterator <a href="index.html#ItemIterator">ItemIterator</a>)</pre>
  277. <p>
  278. Ascend calls the iterator for every value in the tree within the range
  279. [first, last], until iterator returns false.
  280. </p>
  281. <h3 id="BTree.AscendGreaterOrEqual">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=19063:19134#L641">AscendGreaterOrEqual</a></h3>
  282. <pre>func (t *<a href="index.html#BTree">BTree</a>) AscendGreaterOrEqual(pivot <a href="index.html#Item">Item</a>, iterator <a href="index.html#ItemIterator">ItemIterator</a>)</pre>
  283. <p>
  284. AscendGreaterOrEqual calls the iterator for every value in the tree within
  285. the range [pivot, last], until iterator returns false.
  286. </p>
  287. <h3 id="BTree.AscendLessThan">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=18764:18829#L632">AscendLessThan</a></h3>
  288. <pre>func (t *<a href="index.html#BTree">BTree</a>) AscendLessThan(pivot <a href="index.html#Item">Item</a>, iterator <a href="index.html#ItemIterator">ItemIterator</a>)</pre>
  289. <p>
  290. AscendLessThan calls the iterator for every value in the tree within the range
  291. [first, pivot), until iterator returns false.
  292. </p>
  293. <h3 id="BTree.AscendRange">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=18441:18522#L623">AscendRange</a></h3>
  294. <pre>func (t *<a href="index.html#BTree">BTree</a>) AscendRange(greaterOrEqual, lessThan <a href="index.html#Item">Item</a>, iterator <a href="index.html#ItemIterator">ItemIterator</a>)</pre>
  295. <p>
  296. AscendRange calls the iterator for every value in the tree within the range
  297. [greaterOrEqual, lessThan), until iterator returns false.
  298. </p>
  299. <h3 id="BTree.Delete">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=17507:17545#L589">Delete</a></h3>
  300. <pre>func (t *<a href="index.html#BTree">BTree</a>) Delete(item <a href="index.html#Item">Item</a>) <a href="index.html#Item">Item</a></pre>
  301. <p>
  302. Delete removes an item equal to the passed in item from the tree, returning
  303. it. If no such item exists, returns nil.
  304. </p>
  305. <h3 id="BTree.DeleteMax">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=17878:17910#L601">DeleteMax</a></h3>
  306. <pre>func (t *<a href="index.html#BTree">BTree</a>) DeleteMax() <a href="index.html#Item">Item</a></pre>
  307. <p>
  308. DeleteMax removes the largest item in the tree and returns it.
  309. If no such item exists, returns nil.
  310. </p>
  311. <h3 id="BTree.DeleteMin">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=17697:17729#L595">DeleteMin</a></h3>
  312. <pre>func (t *<a href="index.html#BTree">BTree</a>) DeleteMin() <a href="index.html#Item">Item</a></pre>
  313. <p>
  314. DeleteMin removes the smallest item in the tree and returns it.
  315. If no such item exists, returns nil.
  316. </p>
  317. <h3 id="BTree.Descend">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=20556:20602#L686">Descend</a></h3>
  318. <pre>func (t *<a href="index.html#BTree">BTree</a>) Descend(iterator <a href="index.html#ItemIterator">ItemIterator</a>)</pre>
  319. <p>
  320. Descend calls the iterator for every value in the tree within the range
  321. [last, first], until iterator returns false.
  322. </p>
  323. <h3 id="BTree.DescendGreaterThan">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=20265:20334#L677">DescendGreaterThan</a></h3>
  324. <pre>func (t *<a href="index.html#BTree">BTree</a>) DescendGreaterThan(pivot <a href="index.html#Item">Item</a>, iterator <a href="index.html#ItemIterator">ItemIterator</a>)</pre>
  325. <p>
  326. DescendGreaterThan calls the iterator for every value in the tree within
  327. the range (pivot, last], until iterator returns false.
  328. </p>
  329. <h3 id="BTree.DescendLessOrEqual">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=19964:20033#L668">DescendLessOrEqual</a></h3>
  330. <pre>func (t *<a href="index.html#BTree">BTree</a>) DescendLessOrEqual(pivot <a href="index.html#Item">Item</a>, iterator <a href="index.html#ItemIterator">ItemIterator</a>)</pre>
  331. <p>
  332. DescendLessOrEqual calls the iterator for every value in the tree within the range
  333. [pivot, first], until iterator returns false.
  334. </p>
  335. <h3 id="BTree.DescendRange">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=19635:19717#L659">DescendRange</a></h3>
  336. <pre>func (t *<a href="index.html#BTree">BTree</a>) DescendRange(lessOrEqual, greaterThan <a href="index.html#Item">Item</a>, iterator <a href="index.html#ItemIterator">ItemIterator</a>)</pre>
  337. <p>
  338. DescendRange calls the iterator for every value in the tree within the range
  339. [lessOrEqual, greaterThan), until iterator returns false.
  340. </p>
  341. <h3 id="BTree.Get">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=20804:20838#L695">Get</a></h3>
  342. <pre>func (t *<a href="index.html#BTree">BTree</a>) Get(key <a href="index.html#Item">Item</a>) <a href="index.html#Item">Item</a></pre>
  343. <p>
  344. Get looks for the key item in the tree, returning it. It returns nil if
  345. unable to find that item.
  346. </p>
  347. <h3 id="BTree.Has">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=21210:21244#L713">Has</a></h3>
  348. <pre>func (t *<a href="index.html#BTree">BTree</a>) Has(key <a href="index.html#Item">Item</a>) <a href="../../../builtin/index.html#bool">bool</a></pre>
  349. <p>
  350. Has returns true if the given key is in the tree.
  351. </p>
  352. <h3 id="BTree.Len">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=21334:21359#L718">Len</a></h3>
  353. <pre>func (t *<a href="index.html#BTree">BTree</a>) Len() <a href="../../../builtin/index.html#int">int</a></pre>
  354. <p>
  355. Len returns the number of items currently in the tree.
  356. </p>
  357. <h3 id="BTree.Max">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=21105:21131#L708">Max</a></h3>
  358. <pre>func (t *<a href="index.html#BTree">BTree</a>) Max() <a href="index.html#Item">Item</a></pre>
  359. <p>
  360. Max returns the largest item in the tree, or nil if the tree is empty.
  361. </p>
  362. <h3 id="BTree.Min">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=20979:21005#L703">Min</a></h3>
  363. <pre>func (t *<a href="index.html#BTree">BTree</a>) Min() <a href="index.html#Item">Item</a></pre>
  364. <p>
  365. Min returns the smallest item in the tree, or nil if the tree is empty.
  366. </p>
  367. <h3 id="BTree.ReplaceOrInsert">func (*BTree) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=16819:16866#L564">ReplaceOrInsert</a></h3>
  368. <pre>func (t *<a href="index.html#BTree">BTree</a>) ReplaceOrInsert(item <a href="index.html#Item">Item</a>) <a href="index.html#Item">Item</a></pre>
  369. <p>
  370. ReplaceOrInsert adds the given item to the tree. If an item in the tree
  371. already equals the given one, it is removed from the tree and returned.
  372. Otherwise, nil is returned.
  373. </p>
  374. <p>
  375. nil cannot be added to the tree (will panic).
  376. </p>
  377. <h2 id="FreeList">type <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=3258:3300#L70">FreeList</a></h2>
  378. <pre>type FreeList struct {
  379. <span class="comment">// contains filtered or unexported fields</span>
  380. }</pre>
  381. <p>
  382. FreeList represents a free list of btree nodes. By default each
  383. BTree has its own FreeList, but multiple BTrees can share the same
  384. FreeList.
  385. Two Btrees using the same freelist are not safe for concurrent write access.
  386. </p>
  387. <h3 id="NewFreeList">func <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=3397:3433#L76">NewFreeList</a></h3>
  388. <pre>func NewFreeList(size <a href="../../../builtin/index.html#int">int</a>) *<a href="index.html#FreeList">FreeList</a></pre>
  389. <p>
  390. NewFreeList creates a new free list.
  391. size is the maximum size of the returned free list.
  392. </p>
  393. <h2 id="Int">type <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=21433:21445#L723">Int</a></h2>
  394. <pre>type Int <a href="../../../builtin/index.html#int">int</a></pre>
  395. <p>
  396. Int implements the Item interface for integers.
  397. </p>
  398. <h3 id="Int.Less">func (Int) <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=21488:21518#L726">Less</a></h3>
  399. <pre>func (a <a href="index.html#Int">Int</a>) Less(b <a href="index.html#Item">Item</a>) <a href="../../../builtin/index.html#bool">bool</a></pre>
  400. <p>
  401. Less returns true if int(a) &lt; int(b).
  402. </p>
  403. <h2 id="Item">type <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=2623:2915#L48">Item</a></h2>
  404. <pre>type Item interface {
  405. <span class="comment">// Less tests whether the current item is less than the given argument.</span>
  406. <span class="comment">//</span>
  407. <span class="comment">// This must provide a strict weak ordering.</span>
  408. <span class="comment">// If !a.Less(b) &amp;&amp; !b.Less(a), we treat this to mean a == b (i.e. we can only</span>
  409. <span class="comment">// hold one of either a or b in the tree).</span>
  410. Less(than <a href="index.html#Item">Item</a>) <a href="../../../builtin/index.html#bool">bool</a>
  411. }</pre>
  412. <p>
  413. Item represents a single object in the tree.
  414. </p>
  415. <h2 id="ItemIterator">type <a href="http://localhost:6060/src/github.com/google/btree/btree.go?s=4025:4060#L100">ItemIterator</a></h2>
  416. <pre>type ItemIterator func(i <a href="index.html#Item">Item</a>) <a href="../../../builtin/index.html#bool">bool</a></pre>
  417. <p>
  418. ItemIterator allows callers of Ascend* to iterate in-order over portions of
  419. the tree. When this function returns false, iteration will stop and the
  420. associated Ascend* function will immediately return.
  421. </p>
  422. <div id="footer">
  423. Build version go1.6.<br>
  424. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  425. the content of this page is licensed under the
  426. Creative Commons Attribution 3.0 License,
  427. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  428. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  429. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  430. </div>
  431. </div><!-- .container -->
  432. </div><!-- #page -->
  433. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  434. <script type="text/javascript" src="../../../../lib/godoc/jquery.js"></script>
  435. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.js"></script>
  436. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.edit.js"></script>
  437. <script type="text/javascript" src="../../../../lib/godoc/godocs.js"></script>
  438. </body>
  439. </html>