1
1
# Fast Sorted Collections for Swift<br >Using In-Memory B-Trees
2
2
3
3
[ ![ Swift 4.0] ( https://img.shields.io/badge/Swift-4.0-blue.svg )] ( https://swift.org )
4
- [ ![ License] ( https://img.shields.io/badge/licence-MIT-blue.svg )] ( https://github.com/lorentey /BTree/blob/master/LICENSE.md )
4
+ [ ![ License] ( https://img.shields.io/badge/licence-MIT-blue.svg )] ( https://github.com/attaswift /BTree/blob/master/LICENSE.md )
5
5
[ ![ Platform] ( https://img.shields.io/badge/platforms-macOS%20∙%20iOS%20∙%20watchOS%20∙%20tvOS-blue.svg )] ( https://developer.apple.com/platforms/ )
6
6
7
- [ ![ Build Status] ( https://travis-ci.org/lorentey /BTree.svg?branch=master )] ( https://travis-ci.org/lorentey /BTree )
8
- [ ![ Code Coverage] ( https://codecov.io/github/lorentey /BTree/coverage.svg?branch=master )] ( https://codecov.io/github/lorentey /BTree?branch=master )
7
+ [ ![ Build Status] ( https://travis-ci.org/attaswift /BTree.svg?branch=master )] ( https://travis-ci.org/attaswift /BTree )
8
+ [ ![ Code Coverage] ( https://codecov.io/github/attaswift /BTree/coverage.svg?branch=master )] ( https://codecov.io/github/attaswift /BTree?branch=master )
9
9
10
10
[ ![ Carthage compatible] ( https://img.shields.io/badge/Carthage-compatible-4BC51D.svg )] ( https://github.com/Carthage/Carthage )
11
11
[ ![ CocoaPod Version] ( https://img.shields.io/cocoapods/v/BTree.svg )] ( http://cocoapods.org/pods/BTree )
@@ -118,7 +118,7 @@ Each node in the tree also maintains the count of all elements under it.
118
118
This makes the tree an [ order statistic tree] , where efficient positional lookup is possible.
119
119
120
120
[ B-tree wiki ] : https://en.wikipedia.org/wiki/B-tree
121
- [ red-black tree ] : https://github.com/lorentey /RedBlackTree
121
+ [ red-black tree ] : https://github.com/attaswift /RedBlackTree
122
122
[ avl wiki ] : https://en.wikipedia.org/wiki/AVL_tree
123
123
[ order statistic tree ] : https://en.wikipedia.org/wiki/Order_statistic_tree
124
124
[ b-plus tree ] : https://en.wikipedia.org/wiki/B%2B_tree
@@ -132,7 +132,7 @@ tree-based data structures. This is a result of the Swift engineering team spend
132
132
> Indeed, the library lacks even a basic [ double-ended queue] [ deque ] construct --
133
133
> although Cocoa's ` Foundation ` framework does include one in ` NSArray ` .
134
134
135
- [ deque ] : https://github.com/lorentey /Deque
135
+ [ deque ] : https://github.com/attaswift /Deque
136
136
137
137
However, some problems call for a wider variety of data structures.
138
138
@@ -390,7 +390,7 @@ Let's enumerate:
390
390
that you cannot mix-n-match trees of different orders.) Thus, on a 64-bit system, a B-tree
391
391
holding ` Int ` elements will store about 2047 elements per node. Wow!
392
392
393
- [ bTreeNodeSize ] : https://github.com/lorentey /BTree/blob/master/Sources/BTreeNode.swift#L23
393
+ [ bTreeNodeSize ] : https://github.com/attaswift /BTree/blob/master/Sources/BTreeNode.swift#L23
394
394
395
395
- Individual B-tree nodes may be independently shared between multiple B-trees. When mutating a
396
396
(partially or fully) shared tree, copy-on-write is restricted to only clone the nodes whose subtree is
@@ -465,17 +465,17 @@ Let's enumerate:
465
465
to allow for super speedy elementwise insertions and removals. The counts are carefully recalculated
466
466
whenever the path moves off a node's branch in the tree.
467
467
468
- [ BTreePath ] : https://github.com/lorentey /BTree/blob/master/Sources/BTreePath.swift
469
- [ BTreeWeakPath ] : https://github.com/lorentey /BTree/blob/master/Sources/BTreeIndex.swift#L87
470
- [ BTreeStrongPath ] : https://github.com/lorentey /BTree/blob/master/Sources/BTreeIterator.swift#L74
471
- [ BTreeCursorPath ] : https://github.com/lorentey /BTree/blob/master/Sources/BTreeCursor.swift#L96
468
+ [ BTreePath ] : https://github.com/attaswift /BTree/blob/master/Sources/BTreePath.swift
469
+ [ BTreeWeakPath ] : https://github.com/attaswift /BTree/blob/master/Sources/BTreeIndex.swift#L87
470
+ [ BTreeStrongPath ] : https://github.com/attaswift /BTree/blob/master/Sources/BTreeIterator.swift#L74
471
+ [ BTreeCursorPath ] : https://github.com/attaswift /BTree/blob/master/Sources/BTreeCursor.swift#L96
472
472
473
473
- It would be overkill to create an explicit path to look up or modify a single element in the tree
474
474
on its own, so ` BTree ` also provides a [ set of recursive methods] [ BTree-lookups ] that
475
475
implement the same sort of lookups and simple mutations.
476
476
They are faster when you need to retrieve a single item, but they aren't efficient when called repeatedly.
477
477
478
- [ BTree-lookups ] : https://github.com/lorentey /BTree/blob/master/Sources/BTree.swift#L280-L419
478
+ [ BTree-lookups ] : https://github.com/attaswift /BTree/blob/master/Sources/BTree.swift#L280-L419
479
479
480
480
- ` BTree ` includes a [ bulk loading algorithm] [ BTree.bulkLoad ] that efficiently initializes fully loaded
481
481
trees from any sorted sequence. You can also specify a fill factor that's less than 100% if you expect to
@@ -488,7 +488,7 @@ Let's enumerate:
488
488
appending entire B-trees. This comes useful in optimized tree merging algorithms.
489
489
490
490
[ BTree.bulkLoad ] : http://lorentey.github.io/BTree/api/Structs/BTree.html#/s:FV5BTree5BTreecuRd__s8SequenceWd__8Iterator7Element_zTxq__rFT14sortedElementsqd__14dropDuplicatesSb5orderSi10fillFactorSd_GS0_xq__
491
- [ BTreeBuilder ] : https://github.com/lorentey /BTree/blob/master/Sources/BTreeBuilder.swift
491
+ [ BTreeBuilder ] : https://github.com/attaswift /BTree/blob/master/Sources/BTreeBuilder.swift
492
492
493
493
- [ Constructing a B-tree from an unsorted sequence of elements] [ BTree.unsorted-load ] inserts the elements into the tree one by
494
494
one; no buffer is allocated to sort elements before loading them into the tree. This is done more
@@ -509,7 +509,7 @@ Let's enumerate:
509
509
tree merging construct called [ ` BTreeMerger ` ] [ BTreeMerger ] .
510
510
511
511
[ BTree ] : http://lorentey.github.io/BTree/api/Structs/BTree.html
512
- [ BTreeNode ] : https://github.com/lorentey /BTree/blob/master/Sources/BTreeNode.swift
512
+ [ BTreeNode ] : https://github.com/attaswift /BTree/blob/master/Sources/BTreeNode.swift
513
513
[ BTreeKeySelector ] : http://lorentey.github.io/BTree/api/Enums/BTreeKeySelector.html
514
514
[ BTreeIterator ] : http://lorentey.github.io/BTree/api/Structs/BTreeIterator.html
515
515
[ BTreeIndex ] : http://lorentey.github.io/BTree/api/Structs/BTreeIndex.html
@@ -520,7 +520,7 @@ Let's enumerate:
520
520
[ BTree.subtree ] : http://lorentey.github.io/BTree/api/Structs/BTree.html#/s:FV5BTree5BTree7subtreeFT4fromx2tox_GS0_xq__
521
521
[ BTree.union ] : http://lorentey.github.io/BTree/api/Structs/BTree.html#/s:FV5BTree5BTree5unionFTGS0_xq__2byOS_21BTreeMatchingStrategy_GS0_xq__
522
522
[ BTree.symmetricDifference ] : http://lorentey.github.io/BTree/api/Structs/BTree.html#/s:FV5BTree5BTree19symmetricDifferenceFTGS0_xq__2byOS_21BTreeMatchingStrategy_GS0_xq__
523
- [ BTreeMerger ] : https://github.com/lorentey /BTree/blob/master/Sources/BTreeMerger.swift#L318
523
+ [ BTreeMerger ] : https://github.com/attaswift /BTree/blob/master/Sources/BTreeMerger.swift#L318
524
524
525
525
### <a name =" generics " >Remark on Performance of Imported Generics</a >
526
526
<a name =" perf " ></a >
0 commit comments