Add optional args to XLEN to specify start ID and direction #1251
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Syntax:
XLEN stream_name [entry_id] [direction]
.Where direction can be '-' or '+' (special IDs mean respectively the first and the last elements in the stream). Default value: '+'.
If an optional entry ID is specified, the XLEN command returns the number of entries between that ID and the first/last element of the stream.
The element with the specified ID is not considered - it serves as an exclusive boundary. If the stream doesn't contain an entry with the specified ID, the command starts counting from the closest entry to the first/last element in the stream.
If the specified ID is equal to or greater than the last entry ID and:
a) direction is '+' - the command returns 0
b) direction is '-' - the command returns the stream's size
If the specified ID is equal to or less than the first entry ID and:
a) direction is '-' the command returns 0
b) direction is '+' the command returns stream's size
This feature is helpful in finding:
a) how many entries in the stream were processed so far
b) how many unprocessed entries (ahead of the current one) are in the stream
Complexity: O(n)