FIND YOUR NEXT FEW LINES

Results for “compare”

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

68 snippets foundClear filters
C#Collections & data structures

Use case-insensitive dictionary keys

C#: Choose an ordinal comparer when case-insensitive keys represent identifiers.

C#✓ Tested
CSSResponsive conditions & sizing

Adapt a layout to viewport orientation

CSS: The orientation query compares viewport dimensions rather than detecting a physical device type.

CSS✓ Tested
C++Filesystem operations

Calculate a lexical relative path

C++: lexically_relative compares path components without requiring the paths to exist.

C++✓ Tested
Linux CommandsArchives & checksums

Calculate a SHA-256 checksum

Calculate a file checksum so you can compare it with a hash from a trusted source and detect changed contents.

checksum✓ Tested
JavaScriptArray restructuring

Calculate differences between adjacent readings

JavaScript: Slice off the first value and compare each remaining value with its predecessor.

JavaScript✓ Tested
TypeScriptArray restructuring

Calculate differences between adjacent readings

TypeScript: Slice off the first value and compare each remaining value with its predecessor.

TypeScript✓ Tested
C++Text validation & parsing

Check a literal prefix in C++17

C++: Use string compare because starts_with was introduced after C++17.

C++✓ Tested
CStrings & byte buffers

Check a literal string prefix

C: strncmp compares at most the prefix length; both inputs must be valid strings.

C✓ Tested
CDynamic memory & ownership

Check an array allocation size before multiplying

C: Compare the requested element count against SIZE_MAX divided by element size.

C✓ Tested
C++Numeric parsing & calculations

Check an upper integer bound before adding

C++: For these nonnegative values, compare against the maximum minus the addend first.

C++✓ Tested
Bash ScriptsArray operations

Check exact array membership

Bash Scripts: Compare each element literally instead of searching a concatenated string.

Bash Scripts✓ Tested
PythonMappings & sets

Check whether all required keys exist

Python: Compare the required key set with a dictionary key view.

Python✓ Tested