Multiset Partition by Key Bank
Partition a typed multiset by exact caller-supplied scalar key identities while retaining multiplicities and first-appearance order.
Description
Partition a typed multiset by exact caller-supplied scalar key identities while retaining multiplicities and first-appearance order.
Partitioning a multiset by a key bank preserves the full count of every selected value.
When to use this tool
Partition a typed multiset by exact caller-supplied scalar key identities while retaining multiplicities and first-appearance order.
- Prepare the supplied countsJson, keysJson fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter countsJson, keysJson. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.selected, result.remainder. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Normalize countsJson value/count records, parse keysJson as a JSON list and compare their serialized typed keys. Return matching count rows as selected and all others as remainder.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| countsJson | JSON text, entered as one text field. The decoded structure is illustrated below; it is not a separate file. | Text |
| keysJson | JSON text, entered as one text field. The decoded structure is illustrated below; it is not a separate file. | Text |
For the JSON text fields, the following decoded structures show the example records before they are serialized into input strings. Keep field names, list nesting and value types as shown.
[
{
"field": "countsJson",
"decoded": [
{
"value": "a",
"count": 3
},
{
"value": "b",
"count": 1
}
]
},
{
"field": "keysJson",
"decoded": [
"a"
]
}
] | Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.selected | The selected list in the ordering and representation described above. |
| result.remainder | The remainder list in the ordering and representation described above. |
{
"input": {
"countsJson": "[{\"value\":\"a\",\"count\":3},{\"value\":\"b\",\"count\":1}]",
"keysJson": "[\"a\"]"
},
"output": {
"result": {
"selected": [
{
"value": "a",
"count": 3
}
],
"remainder": [
{
"value": "b",
"count": 1
}
]
}
}
} Limitations and assumptions
- Keys absent from the multiset add nothing. No count splitting or external schema coercion is performed.
- All declared input fields are required and unexpected top-level fields are rejected. Numbers must be finite; lists are limited to 128 entries and ordinary text fields to 8,192 UTF-16 code units, with tighter limits where stated.
- JSON text inputs must parse within bounded nesting and size limits. Numeric outputs outside the safe finite range are rejected; large exact integer results use decimal strings. Indexes and half-open spans are zero-based unless a rank is explicitly described as one-based.
Alternative or Complementary methods
Keep occurrence sequences separate from count tables. Choose maximum union, additive concatenation or allocation deliberately, and apply any real inventory changes through a system that controls concurrent updates.
References
Similar or alternative tools
- Multiset Capped Count Table
Cap each normalized typed multiplicity at an explicit nonnegative integer and omit resulting zeros; no proportional redistribution.
- Multiset Complete Kit Count
Count complete typed kits consumable from an explicit inventory using the limiting required multiplicity; empty kit requirements are rejected.