6 Commits
Author SHA1 Message Date
Vihan Bhargava e67460c942 Finish builder and
Key Changes:
 - Implement Equatable, Hashable for SubSequences
 - Implement SortedDictionary initializers
   - init(keysWithValues:) and init(sortedKeysAndValues:) with named and unnamed variants.
 - Expand benchmark suite for SortedDictionary
 - Commit _BTree.Builder

Minor Changes:
 - Update documentation
 - Expand test suits
 - Fix bug where SubSequences did not define subscript(bounds: Range<Index>)
 - _Node
   - Implement `depth` property for `_Node`
     - Packs both `depth`, `count`, and `capacity` within a single UInt64.
   - Implement `init(leftChild:seperator:rightChild:capacity:)` for `_Node`
   - Implement `concatenateWith(node:seperatedBy:)` to `_Node.UnsafeHandle`
   - Remove bad invariant check on `_Node.UnsafeHandle` deletion subroutines
 - _BTree
   - Add invariant checks as `_BTree.checkInvariants()`
   - Separate `_BTree.*capacity` into `*size` and `*capacity`
 - Make _FixedSizeArray top-level
   - Remove deque behavior.

Documentation:
 - Update complexity documentation style from 'n' to `self.count`

Testing:
 - Expand tests for SortedDictionary
 - Add tests for SortedDictionary.Keys
 - Add tests for _Node.join(...) routines
 - Add tests for _BTree.Builder
 - Restore checkBidirectionalCollection tests for _BTree
2021-08-15 00:22:39 -07:00
Vihan Bhargava 0d0d66f671 Documentation refactors, polishes, and add SubSequences
Key Changes:
 - Add custom SubSequences
 - Custom SortedDictionary.(Keys|Values).Sequence iterator
 - Add SortedDictionary.modifyValue(forKey:default:_:)

Minor Changes:
 - Update documentation
 - Various API optimizations
 - Fix bug where offsetBy:limitedBy: calls did not validate indices
 - Remove unique initializers with documented duplicate handling behavior.
 - Implement _Node.UnsafeHandle.append*() methods
 - SortedSet no longer allocates a 'values' buffer (_Node.Header.values is now optional)

Documentation:
 - Complexity guarantees
   - BidirectionalCollection conformances
   - Sequence/IteratorProtocol methods

Optimizations:
 - Add optimized dictionary value mapping (through Node.init(mappingFrom:_:))
 - Custom _BTree.forEach
 - Greater explicit @inline(__always) annotations throughout.
 - Simplify _BTree: Sequence implementation
 - Move methods to using _BTree.Builder
 - _BTree.FixedSizeArray now uses `withUnsafePointer` to prevent branching.
2021-08-09 19:14:19 -07:00
Vihan Bhargava 5690056991 Add cursor type for imperative tree modification.
Key Changes:
 - Implement _BTree.Cursor for performing efficient mutations on a tree

Minor Changes:
 - New implementation of _BTree.Index and iteration
2021-08-09 19:13:50 -07:00
Vihan Bhargava 8de0b4ff7a Implement primary SortedSet methods and various refactors.
Key Changes:
 - SortedSet
   - Implement Partial RangeReplaceableCollection
   - Implement ExpressibleByArrayLiteral
   - Implement init<S: Sequence>(_: S)
   - Implement Set methods:
     - update(with:) / insert(_:) / contains(_:)
 - SortedDictionary
   - Implement SortedDictionary.Values: BidirectionalCollection
   - Implement SortedDictionary.Keys: BidirectionalCollection
 - _BTree
   - Implement Partial RangeReplaceableCollection
   - Implement Sequence
     - Add high performance linear iterator

Minor Changes:
 - Benchmarks
   - Clean up benchmarks
 - _Node.UnsafeHandle
   - @freeze enum InsertionResult
 - _Node.Storage
   - Use UnsafeMutablePointer instead of ManagedBuffer

Refactors:
 - Various refactors for method signatures and documentation.
2021-08-09 19:13:50 -07:00
Vihan Bhargava 3d5d5acb5b Implement B-Tree deletion and respective tests.
Key Changes:
 - Implement removal through SortedDictionary subscript
 - Implement _BTree.contains for efficient existence checking
 - Add tests
   - _Node.UnsafeHandle.rotation/collapse tests
   - _BTree.removeAny tests
 - Expand benchmarks
   - Add C++ reference lookup benchmarks
   - Correct old benchmarks

Minor Changes:
 - Remove B-Tree benchmarks, correct SortedDictionary benchmarks
 - Adjust debug B-Tree printer to show both numElements and numTotalElements
 - Add total count synchronization invariant check
 - Implement CustomReflectable for B-Tree
2021-08-09 19:13:50 -07:00
Vihan Bhargava 9cf2cdadc0 Initial commit for SortedCollections
Signed-off-by: Vihan Bhargava <vihan_bhargava@apple.com>
2021-08-09 19:13:41 -07:00