FIND YOUR NEXT FEW LINES

Results for “key”

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

160 snippets foundClear filters
C++Ordering & set operations

Find the insertion position for a sorted value

C++: lower_bound returns the first position whose value is not less than the search key.

C++✓ Tested
PostgresRows & writes

Get the latest row in each group

Select one ordered row per key with DISTINCT ON.

DISTINCT ON✓ Tested
JavaScriptObject behavior & collections

Group records into map entries

JavaScript: Initialize an array for a missing Map key before appending its values.

JavaScript✓ Tested
TypeScriptObject behavior & collections

Group records into map entries

TypeScript: Initialize an array for a missing Map key before appending its values.

TypeScript✓ Tested
JavaStream transformations

Group strings by their length

Java: Choose a TreeMap supplier when group keys must have deterministic order.

Java✓ Tested
SQLRelationships & missing data

Include zero counts for missing relationships

SQL: Count the non-null child key after a left join so a missing relationship produces zero.

SQL✓ Tested
SQL ServerRelationships & missing data

Include zero counts for missing relationships

SQL Server: Count the non-null child key after a left join so a missing relationship produces zero.

SQL Server✓ Tested
PostgresRelationships & missing data

Include zero counts for missing relationships

Postgres: Count the non-null child key after a left join so a missing relationship produces zero.

Postgres✓ Tested
SQLiteRelationships & missing data

Include zero counts for missing relationships

SQLite: Count the non-null child key after a left join so a missing relationship produces zero.

SQLite✓ Tested
JavaQueues & collection operations

Initialize a map entry only when absent

Java: Use computeIfAbsent when creating a collection for a new key.

Java✓ Tested
PythonMappings & sets

Invert a dictionary with unique values

Python: Swap keys and values when the values are hashable and unique.

Python✓ Tested
SQLGetting Started

Join related rows from two tables

SQL: Match a category key to its display label with an explicit join condition.

SQL✓ Tested