https://github.com/rameel/ramstack.structures
Ramstack.Structures is a .NET library providing various data structures and utilities.
https://github.com/rameel/ramstack.structures
arrayview readonlyarray stringview
Last synced: 9 months ago
JSON representation
Ramstack.Structures is a .NET library providing various data structures and utilities.
- Host: GitHub
- URL: https://github.com/rameel/ramstack.structures
- Owner: rameel
- License: mit
- Created: 2024-06-30T12:29:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-08T03:04:08.000Z (11 months ago)
- Last Synced: 2025-06-10T17:09:36.473Z (9 months ago)
- Topics: arrayview, readonlyarray, stringview
- Language: C#
- Homepage:
- Size: 151 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ramstack.Structures
[](https://nuget.org/packages/Ramstack.Structures)
[](https://github.com/rameel/ramstack.structures/blob/main/LICENSE)
Ramstack.Structures is a .NET library providing various data structures and utilities.
## Installation
To install the `Ramstack.Structures` [NuGet package](https://www.nuget.org/packages/Ramstack.Structures) to your project, use the following command:
```console
dotnet add package Ramstack.Structures
```
## Features
The current release includes primary types:
* `Ramstack.Text.StringView`:
Represents a read-only view of a string, providing safe and efficient access to a subset of its characters.
* `Ramstack.Collections.ArrayView`:
A generic read-only view of an array, allowing safe and efficient access to a subset of its elements.
* `Ramstack.Collections.ReadOnlyArray`:
A generic read-only array wrapper, similar to `ImmutableArray`, but with some performance improvements and better code generation in certain cases.
Additionally, the library provides the `StringViewComparer` class, which offers various comparators accessible through corresponding properties:
| Property | Description |
|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| **Ordinal** | Gets a **StringViewComparer** object that performs a case-sensitive ordinal string comparison. |
| **OrdinalIgnoreCase** | Gets a **StringViewComparer** object that performs a case-insensitive ordinal string comparison. |
| **CurrentCulture** | Gets a **StringViewComparer** object that performs case-sensitive string comparisons using the word comparison rules of the current culture. |
| **CurrentCultureIgnoreCase** | Gets a **StringViewComparer** object that performs case-insensitive string comparisons using the word comparison rules of the current culture. |
| **InvariantCulture** | Gets a **StringViewComparer** object that performs a case-sensitive string comparison using the word comparison rules of the invariant culture. |
| **InvariantCultureIgnoreCase** | Gets a **StringViewComparer** object that performs a case-insensitive string comparison using the word comparison rules of the invariant culture. |
## Notes
The `ArrayView` and `ReadOnlyArray` types have a `ref readonly` indexer, which provides efficient access to elements of the underlying array,
avoiding expensive copying in the case of large structures.
This same optimization is also applied to the enumerators of these types. The `Current` property has a `ref readonly` signature,
which enables the following pattern when necessary:
```csharp
foreach (ref readonly HeavyStruct s in view)
{
...
}
```
## Changelog
### 1.2.2
- Optimize `ArrayView.Create` method for empty collection expression
### 1.2.1
- Add `List` to `ArrayView` extension for NET9.0+
### 1.2.0
- Add `Trim` overloads to `StringView` class
## Supported versions
| | Version |
|------|------------|
| .NET | 6, 7, 8, 9 |
## Contributions
Bug reports and contributions are welcome.
## License
This package is released as open source under the **MIT License**.
See the [LICENSE](LICENSE) file for more details.