Results for “Collections & styling”
Small, practical examples. Search by task or narrow things down below.
Count words using a Map
Update a keyed counter without losing its value type.
Map✓ Tested
Count words with GroupBy
Group repeated C# words and print ordered counts.
C#✓ Tested
Filter a list with a condition
Build a new list containing only the values that satisfy a condition using a list comprehension.
list✓ Tested
Filter and transform an array
Keep active objects and extract their names.
filter✓ Tested
Filter even numbers
Use LINQ Where to keep even C# values.
C#✓ Tested
Filter even numbers
Use a Java stream to collect only even values.
Java✓ Tested
Filter items in a pipeline
Keep numbers that meet a condition.
Where-Object✓ Tested
Look up a dictionary value
Use TryGetValue for a C# dictionary lookup with a fallback.
C#✓ Tested
Look up a map key
Use find to read a C++ map without inserting a missing key.
C++✓ Tested
Merge two dictionaries
Combine two dictionaries into a new dictionary. When a key appears in both inputs, the value from the second dictionary wins.
dictionary✓ Tested
Pair corresponding values from two arrays
PowerShell: Check lengths before indexing to reject mismatched input collections.
PowerShell✓ Tested
Read a map with a default
Return a fallback when a Java map does not contain a key.
Java✓ Tested