Results for “struct”
Small, practical examples. Search by task or narrow things down below.
Reverse a copy while preserving the original
TypeScript: Copy before reverse because reverse mutates the array it receives.
TypeScript✓ Tested
Search a sorted array efficiently
C#: Array.BinarySearch requires an array sorted with the same comparison rules.
C#✓ Tested
Separate a first item from the remaining items
JavaScript: Array destructuring and a rest element produce named pieces of a sequence.
JavaScript✓ Tested
Separate a first item from the remaining items
TypeScript: Array destructuring and a rest element produce named pieces of a sequence.
TypeScript✓ Tested
Serialize a 16-bit integer in big-endian order
C: Explicit shifts make a byte format independent of the CPU’s native byte order.
C✓ Tested
Serialize nested objects with an explicit depth
PowerShell: Select a sufficient depth so nested data is retained instead of converted into a descriptive string.
PowerShell✓ Tested
Split an array into bounded batches
JavaScript: Advance by a positive batch size and allow a shorter final chunk.
JavaScript✓ Tested
Split an array into bounded batches
TypeScript: Advance by a positive batch size and allow a shorter final chunk.
TypeScript✓ Tested
Store a compact configuration record
Arduino / C: Save a struct and retrieve it with the same field layout.
Arduino / C✓ Tested
Track which union member is currently valid
C: An explicit tag tells callers which overlaid union value to read.
C✓ Tested
Use a last-in first-out stack
C#: Stack is useful for reversible traversal and other nested operations.
C#✓ Tested
Use case-insensitive dictionary keys
C#: Choose an ordinal comparer when case-insensitive keys represent identifiers.
C#✓ Tested