Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/draconware-dev/spanextensions.net

SpanExtensions.Net aims to make ReadOnlySpan<T> and Span<T> more accessible and overall better integrated into the .Net Ecosystem, by providing alternatives for many missing Extension Methods for Span<T>, ranging from string.Split() over Enumerable.Skip() and Enumerable.Take() to an improved ReadOnlySpan<T>.IndexOf().
https://github.com/draconware-dev/spanextensions.net

csharp csharp-lib csharp-library dotnet

Last synced: about 1 month ago
JSON representation

SpanExtensions.Net aims to make ReadOnlySpan<T> and Span<T> more accessible and overall better integrated into the .Net Ecosystem, by providing alternatives for many missing Extension Methods for Span<T>, ranging from string.Split() over Enumerable.Skip() and Enumerable.Take() to an improved ReadOnlySpan<T>.IndexOf().

Awesome Lists containing this project

README

        

# SpanExtensions

[![NuGet Badge](https://buildstats.info/nuget/SpanExtensions.Net)](https://www.nuget.org/packages/SpanExtensions.Net)

## About
**`ReadonlySpan`** and **`Span`** are great Types in _C#_, but unfortunately working with them can sometimes be sort of a hassle and some use cases seem straight up impossible, even though they are not.

**SpanExtensions.Net** aims to help developers use `ReadonlySpan` and `Span` more **productively**, **efficiently** and **safely** and write overall more **performant** Programs.

Never again switch back to using `string` instead of `ReadonlySpan`, just because the method you seek is not supported.

**SpanExtensions.Net** provides alternatives for many missing Extension Methods for **`ReadonlySpan`** and **`Span`**, ranging from `string.Split()` over `Enumerable.Skip()` and `Enumerable.Take()` to an improved `ReadOnlySpan.IndexOf()`.

## Methods
The following **Extension Methods** are contained:

#### String Methods made available for **`ReadonlySpan`** and **`Span`**:

- `(ReadOnly-)Span.Split(T delimiter)`
- `(ReadOnly-)Span.Split(T delimiter, int count)`
- `(ReadOnly-)Span.Split(T delimiter, StringSplitOptions options)`
- `(ReadOnly-)Span.Split(T delimiter, StringSplitOptions options, int count)`
- `(ReadOnly-)Span.Split(ReadOnlySpan delimiters)`
- `(ReadOnly-)Span.Split(ReadOnlySpan delimiters, int count)`
- `(ReadOnly-)Span.Split(ReadOnlySpan delimiters, StringSplitOptions options)`
- `(ReadOnly-)Span.Split(ReadOnlySpan delimiters, StringSplitOptions options, int count)`
- `(ReadOnly-)Span.SplitAny(ReadOnlySpan delimiters)`
- `(ReadOnly-)Span.SplitAny(ReadOnlySpan delimiters, int count)`
- `(ReadOnly-)Span.SplitAny(ReadOnlySpan delimiters, StringSplitOptions options)`
- `(ReadOnly-)Span.SplitAny(ReadOnlySpan delimiters, StringSplitOptions options, int count)`
- `(ReadOnly-)Span.Remove(int startIndex)`
- `Span.Replace(T oldT, T newT)`

#### Linq Methods made available for **`ReadonlySpan`** and **`Span`**:

- `(ReadOnly-)Span.All(Predicate predicate)`
- `(ReadOnly-)Span.Any(Predicate predicate)`
- `(ReadOnly-)Span.Average()`
- `(ReadOnly-)Span.Sum()`
- `(ReadOnly-)Span.Skip(int count)`
- `(ReadOnly-)Span.Take(int count)`
- `(ReadOnly-)Span.SkipLast(int count)`
- `(ReadOnly-)Span.Takelast(int count)`
- `(ReadOnly-)Span.SkipWhile(Predicate condition)`
- `(ReadOnly-)Span.TakeWhile(Predicate condition)`
- `(Readonly-)Span.First()`
- `(Readonly-)Span.First(Predicate predicate)`
- `(Readonly-)Span.FirstOrDefault()`
- `(Readonly-)Span.FirstOrDefault(Predicate predicate)`
- `(Readonly-)Span.FirstOrDefault(T defaultValue)`
- `(Readonly-)Span.FirstOrDefault(Predicate predicate, T defaultValue)`
- `(Readonly-)Span.Last()`
- `(Readonly-)Span.Last(Predicate predicate)`
- `(Readonly-)Span.LastOrDefault()`
- `(Readonly-)Span.LastOrDefault(Predicate predicate)`
- `(Readonly-)Span.LastOrDefault(T defaultValue)`
- `(Readonly-)Span.LastOrDefault(Predicate predicate, T defaultValue)`
- `(Readonly-)Span.Single()`
- `(Readonly-)Span.Single(Predicate predicate)`
- `(Readonly-)Span.SingleOrDefault()`
- `(Readonly-)Span.SingleOrDefault(Predicate predicate)`
- `(Readonly-)Span.SingleOrDefault(T defaultValue)`
- `(Readonly-)Span.SingleOrDefault(Predicate predicate, T defaultValue)`
- `(Readonly-)Span.ElementAt(int index)`
- `(Readonly-)Span.ElementAt(Index index)`
- `(Readonly-)Span.ElementAtOrDefault(int index)`
- `(Readonly-)Span.ElementAtOrDefault(Index index)`
- `(Readonly-)Span.ElementAtOrDefault(int index, T defaultValue)`
- `(Readonly-)Span.ElementAtOrDefault(Index index, T defaultValue)`
- `(Readonly-)Span.Min()`
- `(Readonly-)Span.Min(Func selector)`
- `(Readonly-)Span.MinBy(Func keySelector)`
- `(Readonly-)Span.MinBy(Func keySelector, IComparer comparer)`
- `(Readonly-)Span.Max()`
- `(Readonly-)Span.Max(Func selector)`
- `(Readonly-)Span.MaxBy(Func keySelector)`
- `(Readonly-)Span.MaxBy(Func keySelector, IComparer comparer)`

## Contributing

Thank you for your interest in contributing to this project - Please see [Contributing](CONTRIBUTING.md)!
## License

Copyright (c) draconware-dev. All rights reserved.

Licensed under the [MIT](../LICENSE) License.