Trarizon.Library
1.0.0
See the version list below for details.
dotnet add package Trarizon.Library --version 1.0.0
NuGet\Install-Package Trarizon.Library -Version 1.0.0
<PackageReference Include="Trarizon.Library" Version="1.0.0" />
<PackageVersion Include="Trarizon.Library" Version="1.0.0" />
<PackageReference Include="Trarizon.Library" />
paket add Trarizon.Library --version 1.0.0
#r "nuget: Trarizon.Library, 1.0.0"
#:package Trarizon.Library@1.0.0
#addin nuget:?package=Trarizon.Library&version=1.0.0
#tool nuget:?package=Trarizon.Library&version=1.0.0
Trarizon.Library
Miscellaneous Helpers
This library use nuget package CommunityToolkit.HighPerformance and CommunityToolkit.Diagnostics
Contents:
CodeAnalysis
[ExternalSealed]: Indicates a type or interface cannot be inherited or implemented by types in another assembly[BackingFieldAccess]: a workround of .NET 9 backing field[FriendAccess]: Opt-in ver offriendin c++
CodeGeneration
[Singleton]: Generate a singleton class, thread safe with static field[OptionalOut]: Mark it on aoutparameter, a method with same signature without theoutparameter will be generated- Currently does not support multiple
outparameters
- Currently does not support multiple
Collections
- namespace
AllocOpt: Rewrite some collections with struct - namespace
AutoAlloc: Collections with auto allocation and release while modifyingAutoAllocList<>: List
- namespace
Generic: Extension ofSystem.Collections.GenericILinkNode&LinkNodeHelper: Abstraction of linked list node, provides some helper methods inLinkNodeHelperDeque<>: Double-ended queueListDictionary<,>: Generic version ofSystem.Collections.Specialized.ListDictionary.Memento<>: Memento pattern implementation, withAdd,Rollback,ReapplymethodsRingQueue<>: Ring queue with fixed capacity, optional throw or overwrite when fullTrie<>: Trie
- namespace
StackAlloc:ref structcollectionsReadOnlyConcatSpan: Concat 2 spans(ReadOnly)ReversedSpan: Reversed spanStackAllocBitArray: Bit array using aSpan<byte>as underlying items
TraXXX: Static classes with helper method, extension methodsTraAlgorithm:TraArray: Helper forT[],ImmutableArray<>TraComparison: Helpers forIComaprer<>,IComparable, etc.TraDictionary: Helper forDictionary<,>TraEnumerable: Helper forIEnumerable, linq extensionsTraIter: Value type simple Linq, this class is design for instant iterating, so it doesn't support chain linqTraList: Helpers forList<>,I(ReadOnly)List<>TraSpan: Helpers for(ReadOnly)Span<>
Helpers
<details> <summary>Array</summary>
AsEnumerable(OrNull)forImmutableArray<>: Return underlying array asIEnumerable<>to avoid boxing and get performance improvements with LinQ. The BCL overloaded some linq method but not all(and my own linq extensions do not support)MoveTo: Move item onfromIndextotoIndexEmptyIfDefaultforImmutableArray<>: Return empty array if source isnullTryAtforImmutableArray<>
</details>
<details> <summary>Comparison</summary>
Reverse: Reverse aIComparer<>
</details>
<details> <summary>Dictionary</summary>
GetOrAddAddOrUpdate
</details>
<details> <summary>Enumerable</summary>
- Aggregation
CountsMoreThan/LessThan/AtMost/AtLeast/EqualsTo/Between: Judge size of collectionIsDistinct(By): Check if the collection doesn't contains duplicate elementIsInOrder(By): Check if the elements in collection is in orderMinMax(By): Get minimun value and maximun value in one iteration
- Creation
EnumerateByWhile/NotNull: Yield next value selected by aFunc<T, T>, until predicate failed
- Element
TryAt:TryXXXversion ofElementAtTryFirst:TryXXXversion ofFirstTryLast:TryXXXversion ofLastFirstNearToMax(By)(OrDefault): Find the first item has priority greater than given priority, if not found, return the first item with greatest priorityTrySingle: Returning tagged union version ofSingle
- Filtering
Duplicates: Return all elements that is not distinct in collectionOfNotNull: Filter out allnullvaluesTakeEvery: Yield the values in specific interval
- Joining
CatesianProduct: Catesian productMerge: Merge 2 sorted collections
- Mapping
Adjacent: Yield the value and its next valueAggregateSelect:Aggregateand returns all values in processingChunkPair/Triple: Returning tuple version ofChunkWithIndex: Yield index and item,Indexin .NET 9Repeat: Repeatly enumerate the collection
- Partition
OfTypeWhile: Take values until doesn't match the given typeOfTypeUntil: Take values until reach element in given typePopFront: Split the collection into 2 parts, the first parts is return byoutparamterPopFirst: Get the first element, and returns the rest elements.
- Sorting
Rotate: Split the collection into 2 parts and swap them
- ToCollections
EmptyIfNull: Return empty collection if source collection isnullTryToNonEmptyList: If collection is not empty, then collect items intoList<>, in one iteration
</details>
<details> <summary>Iter</summary>
These methods are implements for instant iteration, so all iterators are implements with struct,
but not implements IEnumerable<> or IEnumerator
Too lazy to implement all linqs, so I'll just implement what I have used.
All extensions methods identifiers are start with Iter
- Creation
IterateByWhile/NotNull: Yield next value selected by aFunc<T, T>, until predicate failedRange: Enumerateintfromstarttoend(not include)RangeTo: Iterateintfrom 0 tocountwith specific step
- Mapping
WithIndex
- Sorting
Reverse:Reversein Linq will always cache values in collection, this won't do that because designing for instant iteration
</details>
<details> <summary>List</summary>
- Modification
RemoveAt/RemoveRange: overload forIndexandRangeMoveTo: Move item(s) onfromIndextotoIndex
- Views
GetLookup: Returns a view treating the list as a setGetSortedModifier: Returns a view through which modifying the list will keep elements in order.
</details>
<details> <summary>Span</summary>
- Creation
As(ReadOnly)Bytes: Convert anunmanagedvalue into bytes
- Index
OffsetOf(DangerousOffsetOf) : Get the index of element by pointer substractionFindLower/UppderBoundIndex: find the lower/upper bound in a sorted spanLinearSearch(FromEnd): Linear search, similar toBinarySearch, returns~indexwhen not found
- Modifications
MoveTo: Move item(s) onfromIndextotoIndex
- Views
AsReversed: return(ReadOnly)ReversedSpanof the span
</details>
Wrappers
Either<,>: Monad eitherLazyInitDisposable: Wrapper for fully utilizing theusingstatement when lazy-initIDisposableobjects.Result<,>: Monad Result, for smaller size,TErroronly supports reference type, and ifTErroris null, the result means successOptional<>: Monad Option
More
The namespace structure is almost the same with System.XXX
- namespace
BufferTraArrayPool: Helpers forArrayPoolObjectPool: Object pool
- namespace
ComponentsIFlagNotifiable: Interface for notification, a cheaper and stricterINotifyPropertyChangedFlagNotifiable: Extensions and static methods for global notificationFlagNotifiable<>/<,>: Abstract classes that implementsIFlagNotifiableand provide a methodInvokeNotification, not thread-safeFlagNotifier: Designed as a field to help implementsIFlagNotifiable
- namespace
IOTraPath: ExtendsSystem.IO.PathTraStream: Helpers forSystem.IO.Stream
- namespace
NumericsBoundedInterval: Represents a intervalInterval: Represents a left-close, right-open intervalRay2D/3D: RayTraGeometry: Helpers forVector2/3,Quaternion, etc.TraNumber: Helpers for number types (inSystem.Numerics),Index,Range
- namespace
TextTraString: Helper forstring- namespace
JsonWeakJsonElement: Wrapper ofJsonElementthat auto checkJsonValueKind
- namespace
ThreadingAsyncSemaphoreLock: Async lock implemented withSemaphoreSlimTraAsync: Helpers for async operation,Task<>,ValueTask<>, etc.
TraDelegate: Helpers for delegatesTraEnum: Helpers for enum typesTraRandom: Helpers forRandomTraTuple: Helpers forValueTuplesTraUnsafe: ExtendsUnsafe
Helpers
- ArrayPool
Rent: Overload forArrayPool<>.Rent, returns a auto-return object avaible withusingstatement
- Path
IsValidFile/PathName: check validation of file/path name, withSearchValuesReplaceInvalidFileNameChar: Replace invalid file name characters
- Stream
Read(Exactly): Read data intounmanagedspanReadExactlyIntoArray: Read exactly data into anunmanagedarray with specific lengthReadWithInt32Prefix: Read aintas array length, and doReadExactlyIntoArray
- Number
IncAnd(Try)Wrap: Increment the number, if the result is greater than givenmax, then wrap itNormalize: Linear normalize value into [0,1]NormalizeUnclamped: Linear normalize value into [0,1], but not clampedMapTo: Linear map a value from [a, b] to [c, d], no clampFlipNegative:if (value < 0) value = ~value, useful onBinarySearchresultMin/Max: Overloads forparams ReadOnlySpan<>MinMax(T, T): Reorder input 2 argsMinMax(ROS<T>): Get min and max in one iterationGetCheckedOffset(AndLength):Index/Range.GetOffset(AndLength)with overflow checkCheckSliceArgs: Check ifstartandlengthis valid within a collection
- Geometry
ToNormalized: NormalizeVector2/3,QuaternionToEulerAngles
- Async
GetAwaiter: Supportawaitkeyword forValueTask?,ValueTask<>?CatchCancallation: Return a awaitable that will catchTaskCancellationException.
- Delegate
Create: Create delegate with anobjectand a static method. It is actually the way compiler use to create delegate for extension methods.
- Enum
HasAnyFlag: Check if a enum value has one of given flags.
- Random
SelectWeight: Weighted randomNextSingle/Double: Get a random float number in specific rangeNextBoolean: Get a random boolean valueNextItem: Get a random item in collection
- Tuple
ToKeyValuePair: Convert pair to k-v pair
- Unsafe
AsReadOnly: PerformUnsafe.Asforref readonlyvariables
- Utils
SetField: If given value is not equals to field, set value and returntrue, otherwise returnfalse
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- CommunityToolkit.Diagnostics (>= 8.4.0)
- CommunityToolkit.HighPerformance (>= 8.4.0)
- IndexRange (>= 1.0.3)
- System.Collections.Immutable (>= 9.0.0)
-
.NETStandard 2.1
- CommunityToolkit.Diagnostics (>= 8.4.0)
- CommunityToolkit.HighPerformance (>= 8.4.0)
- System.Collections.Immutable (>= 9.0.0)
-
net8.0
- CommunityToolkit.Diagnostics (>= 8.4.0)
- CommunityToolkit.HighPerformance (>= 8.4.0)
-
net9.0
- CommunityToolkit.Diagnostics (>= 8.4.0)
- CommunityToolkit.HighPerformance (>= 8.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.