Core Library
Core Library
Core utilities and helper functions for general C# development
OmegaLeo.HelperLib
ArrayExtensions
OmegaLeo.HelperLib| Member | Documentation |
|---|---|
Array Extensions |
Set of extension methods to help with Arrays. |
Next |
Method to obtain the next object in the array by passing the current index.
Note: Idea obtained from TaroDev's video on things to do in Unity - https://youtu.be/Ic5ux-tpkCE?t=302 |
BenchmarkUtility
OmegaLeo.HelperLib| Member | Documentation |
|---|---|
BenchmarkUtility |
Utility class for benchmarking code execution time. Example: BenchmarkUtility.Start("MyBenchmark"); // Code to benchmark BenchmarkUtility.Stop("MyBenchmark"); var results = BenchmarkUtility.GetResults("MyBenchmark"); |
Record |
Records the execution time of the provided action and returns the elapsed time in milliseconds. Example: var time = BenchmarkUtility.Record(() => { // Code to benchmark }); Console.WriteLine($"Elapsed time: {time} ms"); |
RecordAndSaveToResults |
Records the execution time of the provided action, saves it under the given key, and returns the elapsed time in milliseconds. Example: var time = BenchmarkUtility.RecordAndSaveToResults("MyBenchmark", () => { // Code to benchmark }); Console.WriteLine($"Elapsed time: {time} ms"); var results = BenchmarkUtility.GetResults("MyBenchmark"); var averageTime = results.Average(); Console.WriteLine($"Average time: {averageTime} ms"); |
Start |
Starts or restarts the stopwatch for the given key. |
Stop |
Stops the stopwatch for the given key and records the elapsed time. |
GetResults |
Retrieves the list of recorded times for the given key. |
ClearResults |
Clears all recorded benchmark results. |
GetAllResults |
Retrieves all recorded benchmark results. |
NeoDictionary`2
OmegaLeo.HelperLib| Member | Documentation |
|---|---|
NeoDictionary |
Dictionary like class created to make it easier to display dictionaries in game engines like Unity |
TryGetValue |
Tries to get the value from the NeoDictionary for the given key. |
TryGetValueFromIndex |
Tries to get the value from the NeoDictionary at the given index. |
Add |
Adds a new NeoDictionaryItem to the NeoDictionary. |
AddRange |
Adds a range of NeoDictionaryItems from another NeoDictionary to the NeoDictionary. |
AddRange |
Adds a range of NeoDictionaryItems to the NeoDictionary. |
Any |
Checks if the NeoDictionary has any items. |
Any |
Checks if any item in the NeoDictionary satisfies a condition. |
Where |
Filters the NeoDictionary items based on a predicate. |
FirstOrDefault |
Returns the first item of the NeoDictionary or a default value if the NeoDictionary is empty. |
FirstOrDefault |
Returns the first item of the NeoDictionary that satisfies a condition or a default value if no such item is found. |
LastOrDefault |
Returns the last item of the NeoDictionary or a default value if the NeoDictionary is empty. |
LastOrDefault |
Returns the last item of the NeoDictionary that satisfies a condition or a default value if no such item is found. |
Select |
Projects each item of the NeoDictionary into a new form. |
IndexOf |
Returns the index of the given NeoDictionaryItem. |
Remove |
Removes the item with the given key. |
RemoveAt |
Removes the item at the given index. |
Replace |
Replaces the value for the given key if it exists. |
HasKey |
Checks if the NeoDictionary contains the given key. |
Clear |
Clears all items from the NeoDictionary. |
Sort |
Sorts the NeoDictionary items using the given comparison. |
Count |
Returns the number of items in the NeoDictionary. |
ForEach |
Performs the given action on each item in the NeoDictionary. |
ToList |
Converts the NeoDictionary items to a List. |
Clone |
Creates a shallow copy of the NeoDictionary. |
Reverse |
Reverses the order of the items in the NeoDictionary. |
Insert |
Inserts an item at the given index. |
InsertRange |
Inserts a range of items starting from the given index. |
RemoveRange |
Removes a range of items starting from the given index. |
RemoveAll |
Removes all items matching the given predicate. |
FindIndex |
Finds the index of the first item matching the given predicate. |
Find |
Finds the first item matching the given predicate. |
FindAll |
Finds all items matching the given predicate. |
Merge |
Merges another NeoDictionary into this one, ignoring duplicate keys. |
ToDictionarySafe |
Converts the NeoDictionary to a standard Dictionary while safely handling duplicate keys by ignoring them. |