https://github.com/bitvantage/numericrange
Parse and manipulate huge lists of numeric ranges such as 40-70,90,95,300-700,5000.
https://github.com/bitvantage/numericrange
Last synced: 10 months ago
JSON representation
Parse and manipulate huge lists of numeric ranges such as 40-70,90,95,300-700,5000.
- Host: GitHub
- URL: https://github.com/bitvantage/numericrange
- Owner: Bitvantage
- License: agpl-3.0
- Created: 2024-06-26T15:24:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-29T14:59:45.000Z (over 1 year ago)
- Last Synced: 2025-02-08T03:16:52.233Z (11 months ago)
- Language: C#
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Bitvantage.NumericRange
Parse and manipulate huge lists of numeric ranges such as 40-70,90,95,300-700,5000.
## Installing via NuGet Package Manager
```
PM> NuGet\Install-Package Bitvantage.NumericRange
```
## Quick Start
```csharp
var range = NumericRange.Parse("40-70,90,95,300-700,702,5000");
range.Add(701); // 40-70,90,95,300-702,5000
range.Add(1000,2000); // 40-70,90,95,300-702,1000-2000,5000
range.Remove(80,100); // 40-70,300-702,1000-2000,5000
range.Remove(1500); // 40-70,300-702,1000-1499,1501-2000,5000
range.Contains(500); // true;
range.Contains(800); // false;
Console.WriteLine(range.ToString()); // 40-70,300-702,1000-1499,1501-2000,5000
```
## Performance
Internally ranges are stored in a red black tree, the search time of red black trees is O(log n).