Skip to content

Commit

Permalink
- Implement #firstPage and #lastPage on BTree
Browse files Browse the repository at this point in the history
- add testLastPage same as we have for SkipList
  • Loading branch information
MarcusDenker committed Nov 13, 2023
1 parent 5caa55b commit 4dee967
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Soil-Core-Tests/SoilBTreeTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@ SoilBTreeTest >> testLast [
self assert: btree last equals: #[ 8 7 6 5 4 3 2 1 ]
]

{ #category : #tests }
SoilBTreeTest >> testLastPage [

| capacity |
btree maxLevel: 8.
capacity := btree firstPage itemCapacity * 100.

1 to: capacity - 1 do: [ :n |
btree at: n put: #[ 1 2 3 4 5 6 7 8 ] ].
btree at: capacity put: #[ 8 7 6 5 4 3 2 1 ].
self assert: btree pages size equals: 200.
self assert: btree lastPage index equals: 200
]

{ #category : #tests }
SoilBTreeTest >> testPageAddFirst [

Expand Down
10 changes: 10 additions & 0 deletions src/Soil-Core/SoilBasicBTree.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ SoilBasicBTree >> first: anInteger [
^ col
]

{ #category : #accessing }
SoilBasicBTree >> firstPage [
^ self headerPage
]

{ #category : #accessing }
SoilBasicBTree >> flush [
self store flush
Expand Down Expand Up @@ -133,6 +138,11 @@ SoilBasicBTree >> last [
^ self newIterator last
]

{ #category : #accessing }
SoilBasicBTree >> lastPage [
^ self newIterator lastPage
]

{ #category : #accessing }
SoilBasicBTree >> maxLevel: anIntegeer [
"ignored, this allows to switch SkiList and BTree easily"
Expand Down

0 comments on commit 4dee967

Please sign in to comment.