Skip to content

Commit

Permalink
Added RsStream>>#iterator and #reverseIteraror for supporting easiler…
Browse files Browse the repository at this point in the history
… iteration
  • Loading branch information
mumez committed Oct 2, 2024
1 parent 47c114a commit ddcc11f
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
iterating
iterator
^ self iteratorClass on: self
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
iterating
reverseIterator
^ self iterator reversed
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
instance creation
on: aRsStream from: fromId
^ (self on: aRsStream)
initFromId: fromId;
yourself
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
instance creation
on: aRsStream nextFrom: fromId
^ (self on: aRsStream) initFromId: fromId
^ (self on: aRsStream)
initFromId: fromId;
initCurrentId: fromId;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
basicCurrentId
^ currentId
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
actions
by: step do: aBlock whileFalse: endConditionBlock
| entries |
entries := self contentsNextFrom: self currentId count: step.
entries := self entriesFrom: self currentId count: step.
entries do: [ :each |
aBlock value: each.
self currentId: each id ].
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
private
contentsFrom: entryId count: step
^ self stream contentsFrom: entryId count: step
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
currentId

^ currentId
currentId ifNil: [ ^ self fallbackId ].
^ currentId
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
private
entriesFrom: entryId count: step
self isInclusive ifTrue: [ ^ self contentsFrom: entryId count: step ].
^ self contentsNextFrom: entryId count: step
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
private
fallbackId
^ self stream first id
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialization
initCurrentId: fromIdLikeThing
currentId := fromIdLikeThing ifNotNil: [ fromIdLikeThing asStreamMessageId ].
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
initialization
initFromId: fromIdLikeThing
fromId := fromIdLikeThing
ifNil: [ RsStreamMessageId zero ]
ifNotNil: [ fromIdLikeThing asStreamMessageId ].
currentId := fromId
fromId := fromIdLikeThing ifNotNil: [ fromIdLikeThing asStreamMessageId ].
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
isInclusive: aBoolean
isInclusive := aBoolean
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
isInclusive
isInclusive ifNil: [ ^ currentId isNil ].
^ isInclusive
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
converting
reversed
^ RsStreamReverseIterator on: self stream nextFrom: self currentId
^ RsStreamReverseIterator on: self stream nextFrom: self basicCurrentId
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"name",
"stream",
"fromId",
"currentId"
"currentId",
"isInclusive"
],
"name" : "RsStreamIterator",
"type" : "normal"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
private
contentsFrom: entryId count: step
^ self stream contentsReversedFrom: entryId count: step
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
private
fallbackId
^ self stream last id
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
converting
reversed
^ RsStreamIterator on: self stream nextFrom: self currentId
^ RsStreamIterator on: self stream nextFrom: self basicCurrentId

0 comments on commit ddcc11f

Please sign in to comment.