Monthly Archives: December 2020

C++ || How To Get A List Of Files At A Given Path Directory Using C++

The following is a module with functions which demonstrates how to get a list of files at a given directory path using C++.

The function demonstrated on this page returns a list of std::filesystem::directory_entry, which contains information about the files in the given directory.


1. Get Files In Directory

The example below demonstrates the use of ‘Utils::getFilesInDirectory‘ to get a list of files at a given path directory.

The optional function parameter lets you specify the search option. Set the search option to True to limit the search to just the current directory. Set the search option to False to expand the search to the current directory and all subdirectories when searching for files.


2. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


3. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

C++ || How To Make Map & Unordered Map Keys Case Insensitive Using C++

The following is a module with functions which demonstrates how to make map and unordered_map keys case insensitive using C++.


1. Case Insensitive – Map

The example below demonstrates how to make a map with a string key case insensitive.

To do this, the comparison function needs to be overridden.


2. Case Insensitive – Unordered Map

The example below demonstrates how to make an unordered map with a string key case insensitive.

To do this, the comparison and the hash function needs to be overridden.


3. Full Examples

Below is a full example demonstrating the concepts on this page.

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

C++ || How To Search For & Find A Specific Element In A Vector Using C++

The following is a module with functions which demonstrates how to search for and find a specific element in a vector using C++.

The function demonstrated on this page is a template, so it should work on vectors of any type. It also uses a predicate to determine the item to select.


1. Find

The example below demonstrates the use of ‘Utils::find‘ to find the first element in a sequence of values based on a predicate.

The predicate determines the item to find.


2. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


3. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

C++ || How To Filter & Select Items In An Array/Vector/Container & Get The Results Using C++

The following is a module with functions which demonstrates how to filter and select items in an array/vector/container, and get the results using C++.

The function demonstrated on this page is a template, so it should work on containers of any type. It also uses a predicate to determine the items to select.


1. Filter – Integer Array

The example below demonstrates the use of ‘Utils::filter‘ to filter an integer array based on a predicate and return its results.

The predicate determines the items to filter and select.


2. Filter – String Vector

The example below demonstrates the use of ‘Utils::filter‘ to filter a sequence of values based on a predicate and return its results.

The predicate determines the items to filter and select.


3. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


4. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

C++ || How To Check If An Item Exists In A Vector And Get Its Position Index Using C++

The following is a module with functions which demonstrates how to find the position index of an item in a vector, and make sure the item exists using C++.

The functions demonstrated on this page are wrappers for std::find_if function, and are templates, so they should work on vectors/containers of any type.


1. Contains

The example below demonstrates the use of ‘Utils::contains‘ to determine whether an element is contained in the collection.


2. Index Of

The example below demonstrates the use of ‘Utils::indexOf‘ to get the zero based index of the first occurrence of a search value in the collection.


3. Index Of – Predicate

The example below demonstrates the use of ‘Utils::indexOf‘ to get the zero based index of the first occurrence of a search value in the collection.

In this example, a predicate is used to determine the item to search for. This allows you to customize how an item should be searched.


4. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


5. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

C++ || How To Merge & Concatenate Two Vectors Using C++

The following is a module with functions which demonstrates how to merge, concatenate and append two vectors using C++.

The function demonstrated on this page is a template, so it should work on vectors of any type.


1. Add Range

The example below demonstrates the use of ‘Utils::addRange‘ add elements to the end of the collection.


2. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


3. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

C++ || How To Replace All Occurrences Of A String With Another String Using C++

The following is a module with functions which demonstrates how to replace all occurrences of a substring with another substring using C++.


1. Replace All

The example below demonstrates the use of ‘Utils::replaceAll‘ to replace all occurrences of an ‘oldValue’ string with a ‘newValue’ string.


2. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


3. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

C++ || How To Check If A String Is Empty Or Only Contains Whitespace Using C++

The following is a module with functions which demonstrates how to determine whether a string is empty, or consists only of white-space characters using C++.


1. Is Null Or Whitespace

The example below demonstrates the use of ‘Utils::isNullOrWhitespace‘ to determine whether a string is empty, or consists only of white-space characters.


2. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


3. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

C++ || How To Convert A String To Upper and Lower Case Using C++

The following is a module with functions which demonstrates how to convert a string to all upper and lower case using C++.


1. To Upper Case

The example below demonstrates the use of ‘Utils::toUpperCase‘ to convert a string to all upper case.


2. To Lower Case

The example below demonstrates the use of ‘Utils::toLowerCase‘ to convert a string to all lower case.


3. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


4. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

C++ || How To Remove All Whitespace From A String Using C++

The following is a module with functions which demonstrates how to remove all whitespace from a string using C++.


1. Remove All Whitespace

The example below demonstrates the use of ‘Utils::RemoveWhitespace‘ to remove all whitespace from a string.


2. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


3. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

C++ || How To Get The File Path, File Name & File Extension From A Path Using C++

The following is a module with functions which demonstrates how to parse a file path, file name and file extension from a path using C++.


1. Get File Path

The example below demonstrates the use of ‘Utils::getFilePath‘ to parse and get the file path from a path.


2. Get File Name

The example below demonstrates the use of ‘Utils::getFileName‘ to parse and get the file name from a path.


3. Get File Name Extension

The example below demonstrates the use of ‘Utils::getFileExtension‘ to parse and get the file extension from a path.


4. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


5. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

VB.NET || How To Create Multiple Tasks With Maximum Concurrency Using VB.NET

The following is a module with functions which demonstrates how to create multiple tasks with maximum concurrency using VB.NET.

The examples demonstrated on this page uses System.Threading.Tasks.Task to start and run tasks. They also use System.Threading.SemaphoreSlim to limit the number of tasks that can run concurrently.

The examples on this page demonstrates how to start and run multiple tasks with a maximum concurrency. It also demonstrates how to start and run multiple tasks with a return value.


1. Task – Maximum Concurrency

The example below demonstrates how to start and run multiple tasks with a maximum concurrency. For example purposes, the tasks do not return a value.

The functions shown in the example below are called asynchronously, but they can also be called synchronously.


2. Task – Maximum Concurrency – Return Value

The example below demonstrates how to start and run multiple tasks with a maximum concurrency. In this example, a value is returned and retrieved from the tasks

The functions shown in the example below are called asynchronously, but they can also be called synchronously.


3. More Examples

Below is a full example of the process demonstrated on this page!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

VB.NET || How To Convert Bytes To Kilobytes, Megabytes, Gigabytes, Terabytes Using VB.NET

The following is a module with functions which demonstrates how to convert bytes to decimal formats like kilobytes, megabytes, gigabytes, terabytes, petabytes, exabytes, zettabytes, and yottabytes, as well as binary formats like kibibytes, mebibytes, gibibytes, tebibytes, pebibytes, exbibytes, zebibytes, and yobibytes using VB.NET.

The function demonstrated on this page follows the IEC standard, which means:


• 1 kilobyte = 1000 bytes (Decimal)
• 1 kibibyte = 1024 bytes (Binary)

This function allows you to convert bytes to a measurement unit, a measurement unit to bytes, and allows to convert from one measurement unit to another measurement unit.


1. Convert Bytes To Measurement Unit

The example below demonstrates the use of ‘Utils.Bytes.FromTo‘ to convert bytes to a measurement unit.

The optional function parameter allows you to specify the decimal places.


2. Convert Measurement Unit To Bytes

The example below demonstrates the use of ‘Utils.Bytes.FromTo‘ to convert a measurement unit to bytes.

The optional function parameter allows you to specify the decimal places.


3. Convert Measurement Unit To Measurement Unit

The example below demonstrates the use of ‘Utils.Bytes.FromTo‘ to convert a measurement unit to another measurement unit.

The optional function parameter allows you to specify the decimal places.


4. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


5. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

VB.NET || How To Parse A Delimited CSV File Using VB.NET

The following is a module with functions which demonstrates how to parse a delimited CSV file using VB.NET.

The function demonstrated on this page uses FileIO.TextFieldParser to parse values in a CSV file.

This function parses a CSV file and returns its results as a List. Each List index represents a line in the CSV file, with each item in the list representing a record contained on that line.


1. Parse CSV File

The example below demonstrates the use of ‘Utils.ParseCsv‘ to parse a CSV file and return its results as a List.

The optional function parameter allows you to specify the delimiters. Default delimiter is a comma (,).

Sample CSV used in this example is the following:


2. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


3. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.