Skip to content

Commit b0e552c

Browse files
authored
Merge pull request #1 from sakapon/v1.0
v1.0.4
2 parents 9fa8ec7 + 3ab1320 commit b0e552c

File tree

113 files changed

+11168
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+11168
-0
lines changed

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,74 @@
11
# WBTrees
2+
[![license](https://img.shields.io/github/license/sakapon/WBTrees.svg)](LICENSE)
3+
[![NuGet](https://img.shields.io/nuget/v/WBTrees.svg)](https://www.nuget.org/packages/WBTrees/)
4+
[![NuGet](https://img.shields.io/nuget/dt/WBTrees.svg)](https://www.nuget.org/packages/WBTrees/)
5+
26
Provides a basic implementation of weight-balanced binary trees.
7+
8+
The WBTrees library contains classes as follows:
9+
- A list by a weight-balanced binary tree, with all `O(log n)` basic operations
10+
- `WBList<T>`
11+
- A set and a map by weight-balanced binary search trees, which can be accessed by index in `O(log n)` time
12+
- `WBSet<T>`
13+
- `WBMultiSet<T>`
14+
- `WBMap<TKey, TValue>`
15+
- `WBMultiMap<TKey, TValue>`
16+
17+
All these trees are constructed from `Node<T>` objects.
18+
19+
See [Wiki](https://github.com/sakapon/WBTrees/wiki) for more information.
20+
This library is written in C#.
21+
You are welcome to port this to other languages.
22+
23+
## Features
24+
25+
### A List by a Weight-Balanced Binary Tree
26+
Provides the `WBList<T>` class as a list with all `O(log n)` basic operations.
27+
You can also use a `WBList<T>` as a (high-grade) double-ended queue (deque).
28+
29+
The following table compares time complexities of [`System.Collections.Generic.List<T>`](https://docs.microsoft.com/dotnet/api/system.collections.generic.list-1) and `WBList<T>`:
30+
| Operation | `List<T>` | `WBList<T>` |
31+
|:--|:-:|:-:|
32+
| Get by Index | `O(1)` | `O(log n)` |
33+
| Set by Index | `O(1)` | `O(log n)` |
34+
| Remove by Index | `O(n)` | `O(log n)` |
35+
| Insert by Index | `O(n)` | `O(log n)` |
36+
| Prepend | `O(n)` | `O(log n)` |
37+
| Add | `O(1)` | `O(log n)` |
38+
| Get All | `O(n)` | `O(n)` |
39+
40+
### A Set and a Map by Weight-Balanced Binary Search Trees
41+
Provides the `WBSet<T>`, `WBMultiSet<T>`, `WBMap<TKey, TValue>` and `WBMultiMap<TKey, TValue>` classes, which can be accessed by index in `O(log n)` time. All these classes are derived from the `WBTreeBase<T>` class.
42+
You can also use a `WBMultiSet<T>` or a `WBMultiMap<TKey, TValue>` as a priority queue with stable sorting or a double-ended priority queue.
43+
44+
The following table compares time complexities of [`System.Collections.Generic.SortedSet<T>`](https://docs.microsoft.com/dotnet/api/system.collections.generic.sortedset-1) and `WBSet<T>`:
45+
| Operation | `SortedSet<T>` | `WBSet<T>` |
46+
|:--|:-:|:-:|
47+
| Get by Item | `O(log n)` | `O(log n)` |
48+
| Remove by Item | `O(log n)` | `O(log n)` |
49+
| Add | `O(log n)` | `O(log n)` |
50+
| Get by Index | `O(n)` | `O(log n)` |
51+
| Remove by Index | `O(n)` | `O(log n)` |
52+
| Get Index by Item | `O(n)` | `O(log n)` |
53+
| Get All | `O(n)` | `O(n)` |
54+
55+
## Algorithm
56+
Both `WBList<T>` and `WBTreeBase<T>` are weight-balanced binary trees (not necessarily searchable by items).
57+
The `Node<T>` class contains the `Count` property that contributes to both self-balancing and fast access by index (order).
58+
59+
## Target Frameworks
60+
- .NET 5
61+
- .NET Standard 2.0
62+
- [.NET Core 2.0, .NET Framework 4.6.1, etc.](https://docs.microsoft.com/dotnet/standard/net-standard)
63+
64+
## Setup
65+
The WBTrees library is published to [NuGet Gallery](https://www.nuget.org/packages/WBTrees/).
66+
Install the NuGet package via Visual Studio, etc.
67+
68+
You can also [download a single source file here](downloads) for competitive programming, etc.
69+
70+
## Usage
71+
See [Usage on Wiki](https://github.com/sakapon/WBTrees/wiki/Usage) for coding.
72+
73+
## Release Notes
74+
- **v1.0.4** The first release.

0 commit comments

Comments
 (0)