FIND YOUR NEXT FEW LINES

Results for “Array operations”

Small, practical examples. Search by task or narrow things down below.

298 snippets foundClear filters
TypeScriptUTC date operations

Count days between UTC-midnight dates

TypeScript: A day is exactly 86400000 milliseconds for these explicitly UTC-midnight inputs.

TypeScript✓ Tested
C++Ordering & set operations

Count occurrences in a sorted sequence

C++: equal_range finds the half-open interval containing values equal to the key.

C++✓ Tested
CSmall algorithms & bit operations

Count set bits in an unsigned integer

C: Clearing the lowest set bit on each iteration counts only one iteration per set bit.

C✓ Tested
C#File operations & paths

Create a file only when it does not exist

C#: FileMode.CreateNew prevents accidental replacement of existing content.

C#✓ Tested
PythonFile operations & archives

Create a file without overwriting an existing one

Python: Use exclusive creation mode and handle FileExistsError explicitly.

Python✓ Tested
PythonFile operations & archives

Create a ZIP archive from a file

Python: Give a ZIP entry a relative archive name instead of exposing its source directory.

Python✓ Tested
JavaFile operations & binary data

Create and clean up a temporary file

Java: Create a unique file and remove it in finally even when the operation fails.

Java✓ Tested
JavaScriptArray restructuring

Create independent rows in a matrix

JavaScript: Use a mapping function to create each row instead of sharing one array with fill.

JavaScript✓ Tested
TypeScriptArray restructuring

Create independent rows in a matrix

TypeScript: Use a mapping function to create each row instead of sharing one array with fill.

TypeScript✓ Tested
C#File operations & paths

Delete a known scratch file

C#: File.Delete ignores a missing file but still throws for other I/O failures.

C#✓ Tested
JavaFile operations & binary data

Delete a known temporary file if present

Java: deleteIfExists returns whether a file was removed and still reports other I/O errors.

Java✓ Tested
C++Filesystem operations

Delete one known scratch file

C++: filesystem::remove reports whether an item was removed and also supports empty directories.

C++✓ Tested