Skip to content

Commit

Permalink
unify at:ifAbsent: and find:
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusDenker committed Dec 6, 2023
1 parent a72bbe1 commit 85cba79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/Soil-Core/SoilBTreeIterator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ SoilBTreeIterator >> basicAt: key put: anObject [

{ #category : #private }
SoilBTreeIterator >> findPageFor: key [
currentKey := key.
^currentPage := index rootPage find: key with: index
]

Expand Down
19 changes: 13 additions & 6 deletions src/Soil-Core/SoilIndexIterator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ SoilIndexIterator >> at: aKeyObject [
^ self at: aKeyObject ifAbsent: [ KeyNotFound signalFor: aKeyObject in: self ]
]

{ #category : #private }
{ #category : #accessing }
SoilIndexIterator >> at: aKeyObject ifAbsent: aBlock [
currentKey := (aKeyObject asSkipListKeyOfSize: index keySize) asInteger.
self findPageFor: currentKey.
^ currentPage
valueAt: currentKey
ifAbsent: aBlock
^self find: currentKey ifAbsent: aBlock
]

{ #category : #accessing }
Expand All @@ -45,6 +42,11 @@ SoilIndexIterator >> at: aKeyObject put: anObject [
put: anObject
]

{ #category : #accessing }
SoilIndexIterator >> basicAt: key put: anObject [
self subclassResponsibility
]

{ #category : #accessing }
SoilIndexIterator >> currentPage [

Expand All @@ -66,9 +68,14 @@ SoilIndexIterator >> do: aBlock [

{ #category : #private }
SoilIndexIterator >> find: key [
^ self find: key ifAbsent: [ ]
]

{ #category : #private }
SoilIndexIterator >> find: key ifAbsent: aBlock [
currentKey := key.
self findPageFor: key.
^ currentPage valueAt: currentKey
^ currentPage valueAt: key ifAbsent: aBlock
]

{ #category : #private }
Expand Down

0 comments on commit 85cba79

Please sign in to comment.