Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move #isRemoved for #isEmpty from the pages to the SoilIndexedDictionary #518

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/Soil-Core/SoilBTreeDataPage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ SoilBTreeDataPage >> find: aKey with: aBTree [

]

{ #category : #testing }
SoilBTreeDataPage >> hasItems [
^ (items reject: [ :each | each value isRemoved ]) notEmpty
]

{ #category : #utilities }
SoilBTreeDataPage >> headerSize [
^ super headerSize
Expand Down Expand Up @@ -87,12 +82,6 @@ SoilBTreeDataPage >> itemBefore: key [
^ items before: item ifAbsent: nil
]

{ #category : #accessing }
SoilBTreeDataPage >> lastItem [

^ items ifEmpty: nil ifNotEmpty: [ :itms | itms last ]
]

{ #category : #accessing }
SoilBTreeDataPage >> next [
^next
Expand Down
9 changes: 8 additions & 1 deletion src/Soil-Core/SoilBTreePage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ SoilBTreePage >> find: aKey with: aBTree [

{ #category : #accessing }
SoilBTreePage >> firstItem [
^ items first

^ items isNotEmpty ifTrue: [ items first ]
noha marked this conversation as resolved.
Show resolved Hide resolved
]

{ #category : #testing }
Expand Down Expand Up @@ -144,6 +145,12 @@ SoilBTreePage >> keySize: anInteger [
keySize := anInteger
]

{ #category : #accessing }
SoilBTreePage >> lastItem [

^ items isNotEmpty ifTrue: [ items last ]
]

{ #category : #accessing }
SoilBTreePage >> lastTransaction [
^ lastTransaction
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilBasicBTree.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ SoilBasicBTree >> initializeHeaderPage [

{ #category : #testing }
SoilBasicBTree >> isEmpty [
^ self store headerPage hasItems not
^ self store headerPage isEmpty
]

{ #category : #testing }
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilBasicSkipList.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ SoilBasicSkipList >> headerPage [

{ #category : #testing }
SoilBasicSkipList >> isEmpty [
^ self store headerPage hasItems not
^ self store headerPage isEmpty
]

{ #category : #testing }
Expand Down
10 changes: 6 additions & 4 deletions src/Soil-Core/SoilIndexedDictionary.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ SoilIndexedDictionary >> initialize [

{ #category : #testing }
SoilIndexedDictionary >> isEmpty [
^ newValues isEmpty and: [ self index isEmpty ]
^ newValues isEmpty and: [ self index isEmpty
or: [
"all items might be removed"
(self index firstPage items allSatisfy: [ :each | each value isRemoved ])]]
]

{ #category : #testing }
Expand Down Expand Up @@ -326,9 +329,8 @@ SoilIndexedDictionary >> removeKey: key ifAbsent: aBlock [
]

{ #category : #private }
SoilIndexedDictionary >> restoreValue: value forKey: key iterator: iterator [
"restore a value that has been removed by a later
transaction"
SoilIndexedDictionary >> restoreValue: value forKey: key iterator: iterator [
"restore a value that has been removed by a later transaction"
^ value isRemoved
ifTrue: [
self
Expand Down
15 changes: 4 additions & 11 deletions src/Soil-Core/SoilSkipListPage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,8 @@ SoilSkipListPage >> biggestKey [

{ #category : #accessing }
SoilSkipListPage >> firstItem [
^ items
ifNotEmpty: [ items first ]
ifEmpty: nil
]

{ #category : #testing }
SoilSkipListPage >> hasItems [
^ (items reject: [ :each | each value isRemoved ]) notEmpty
^ items isNotEmpty ifTrue: [ items first ]
]

{ #category : #testing }
Expand Down Expand Up @@ -223,14 +217,13 @@ SoilSkipListPage >> keySize: anInteger [
{ #category : #accessing }
SoilSkipListPage >> lastItem [

^ items ifEmpty: nil ifNotEmpty: [ :itms | itms last ]
^ items isNotEmpty ifTrue: [ items last ]
]

{ #category : #accessing }
SoilSkipListPage >> lastKey [
^ items
ifNotEmpty: [ items last key ]
ifEmpty: nil

^ items isNotEmpty ifTrue: [ items last key ]
]

{ #category : #accessing }
Expand Down
Loading