Description
Simulate sampled reads and writes with delegated circular indices, explicit next-read head and next-write tail, occupancy, underflow and selected reject-or-overwrite overflow semantics.
An operation trace pairs an ordered request stream with the state after each step. Empty operations, ties, evictions, and boundary indexes are part of the modeled contract rather than incidental display details.
Simulate sampled reads and writes with delegated circular indices, explicit next-read head and next-write tail, occupancy, underflow and selected reject-or-overwrite overflow semantics.
When to use this tool
Use this generator to create reproducible circular buffer wraparound trace cases from the supplied model or bank. Inspect the returned evidence before using cases in a test or exercise.
How to use the tool and how it works
- Supply capacity, operations, eventCount, minimumValue, maximumValue, overflowPolicy in the field shapes below. Set seed when you need an explicit replay.
- Run the tool and correct any input error. For generated controls, distinguish a successful fixture containing an invalid case from failure to generate the fixture.
- Read events, finalValues. Use the conventions below. Keep answer-bearing fields separate when presenting an exercise.
Sample reads and writes on a fixed circular buffer, delegating wrapped indexes. Reads remove the oldest value; full writes either reject or overwrite and evict it. Return raw cell snapshots, head/tail/size, and final logical FIFO values.1
Delegated operations used for this result: circular buffer index. Their calculation or parsing conventions apply to the corresponding result fields.2
| Input field | Meaning and units | Accepted input |
|---|---|---|
| capacity | Capacity | Required. Safe integer; minimum 1; maximum 16. |
| operations | Operations | Required. Array of Text; one of "read", "write".; minimum items 1; maximum items 2. |
| eventCount | Event Count | Required. Safe integer; minimum 1; maximum 64. |
| minimumValue | Minimum Value | Required. Safe integer. |
| maximumValue | Maximum Value | Required. Safe integer. |
| overflowPolicy | Overflow Policy | Required. Text; one of "reject", "overwrite". |
| seed | Optional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed. | Optional. Safe integer. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| events | Events | Required. Array of Object; no unknown keys.; minimum items 0; maximum items 64. |
| events[].kind | Kind | Required. Text; one of "read", "write". |
| events[].value | Value | Required. Safe integer. or Null. |
| events[].accepted | Accepted | Required. Boolean. |
| events[].overflow | Overflow | Required. Boolean. |
| events[].underflow | Underflow | Required. Boolean. |
| events[].evicted | Evicted | Required. Safe integer. or Null. |
| events[].head | Head | Required. Safe integer; minimum 0; maximum 15. |
| events[].tail | Tail | Required. Safe integer; minimum 0; maximum 15. |
| events[].size | Size | Required. Safe integer; minimum 0; maximum 16. |
| events[].cells | Cells | Required. Array of Safe integer. or Null.; minimum items 1; maximum items 16. |
| finalValues | Final Values | Required. Array of Safe integer.; minimum items 0; maximum items 16. |
| randomness | Replay source and normalized 32-bit seed, or null seed for an advancing context source. | Required. Object; no unknown keys. |
| randomness.seed | Optional safe-integer replay seed; normalization and precedence are explained below. | Required. Safe integer. or Null. |
| randomness.source | Source | Required. Text; one of "context", "seed". |
An explicit safe-integer seed takes precedence over injected context randomness and is normalized to an unsigned 32-bit integer. With no seed and no context source, replay uses the fixed tool.io default seed. A context source must return finite values from zero inclusive to one exclusive; its advancing state must be retained separately. randomness records the source and normalized seed, or null for context. These generators are not cryptographic random sources.
{
"input": {
"capacity": 2,
"operations": [
"read",
"write"
],
"eventCount": 5,
"minimumValue": 1,
"maximumValue": 3,
"overflowPolicy": "overwrite",
"seed": 42
},
"output": {
"events": [
{
"kind": "write",
"value": 2,
"accepted": true,
"overflow": false,
"underflow": false,
"evicted": null,
"head": 0,
"tail": 1,
"size": 1,
"cells": [
2,
null
]
},
{
"kind": "write",
"value": 3,
"accepted": true,
"overflow": false,
"underflow": false,
"evicted": null,
"head": 0,
"tail": 0,
"size": 2,
"cells": [
2,
3
]
},
{
"kind": "read",
"value": 2,
"accepted": true,
"overflow": false,
"underflow": false,
"evicted": null,
"head": 1,
"tail": 0,
"size": 1,
"cells": [
null,
3
]
},
{
"kind": "write",
"value": 1,
"accepted": true,
"overflow": false,
"underflow": false,
"evicted": null,
"head": 1,
"tail": 1,
"size": 2,
"cells": [
1,
3
]
},
{
"kind": "write",
"value": 3,
"accepted": true,
"overflow": true,
"underflow": false,
"evicted": 3,
"head": 0,
"tail": 0,
"size": 2,
"cells": [
1,
3
]
}
],
"finalValues": [
1,
3
],
"randomness": {
"seed": 42,
"source": "seed"
}
}
} Limitations and assumptions
- Equal head and tail can mean empty or full, so inspect size. Rejected operations are intentional trace events. The model is sequential and omits concurrent access, memory ordering, and real storage behavior.
- A replay requires the same complete input and implementation. The stated sampling convention applies within its eligible space. A finite draw does not exhaust all possible outputs; repeats remain possible unless a distinct-selection rule is explicit.
- The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.
Alternative or Complementary methods
For a supplied example, inspect the returned construction or delegated check directly. To evaluate a consumer, also test cases chosen for its own boundaries; a generated finite corpus does not establish exhaustive coverage.
References
Similar or alternative tools
- Two-Table Cuckoo Hashing Trace Tool
Trace insertion evictions, lookups and deletion in two fixed-size integer-key cuckoo tables using h1(k)=k mod m and h2(k)=floor(k/m) mod m; a kick limit rolls back the insertion and signals rehash-needed, without automatic resizing or hash-quality guarantees.
- Random Bitset Membership Operation Trace Generator
Generate bounded set, clear and test operations with exact unsigned words stored in increasing word order and least-significant-bit member positions, using BigInt to avoid signed 32-bit truncation.