Skip to content

Commit 9b00244

Browse files
authored
The first revision (#5)
2 parents 37d96d6 + c698dd7 commit 9b00244

30 files changed

+882
-258
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
16+
1.
17+
18+
**Expected behavior**
19+
A clear and concise description of what you expected to happen.
20+
21+
**Logs**
22+
If applicable, add logs to help explain your problem.
23+
24+
**Additional context**
25+
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Discussions
4+
url: https://github.com/CogitatorTech/ordered/discussions
5+
about: Please ask and answer general questions here
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/workflows/benches.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Run Benchmarks
33
on:
44
workflow_dispatch:
55
push:
6-
branches:
7-
- main
86
tags:
97
- 'v*'
108
pull_request:
@@ -25,7 +23,7 @@ jobs:
2523
- name: Install Zig
2624
uses: goto-bus-stop/setup-zig@v2
2725
with:
28-
version: '0.15.1'
26+
version: '0.15.2'
2927

3028
- name: Install Dependencies
3129
run: |

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Install Zig
2020
uses: goto-bus-stop/setup-zig@v2
2121
with:
22-
version: '0.15.1'
22+
version: '0.15.2'
2323

2424
- name: Install System Dependencies
2525
run: |

.github/workflows/lints.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Install Zig
2424
uses: goto-bus-stop/setup-zig@v2
2525
with:
26-
version: '0.15.1'
26+
version: '0.15.2'
2727

2828
- name: Install Dependencies
2929
run: |

.github/workflows/tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Run Tests
33
on:
44
workflow_dispatch:
55
push:
6-
branches:
7-
- main
86
tags:
97
- 'v*'
108
pull_request:
@@ -25,7 +23,7 @@ jobs:
2523
- name: Install Zig
2624
uses: goto-bus-stop/setup-zig@v2
2725
with:
28-
version: '0.15.1'
26+
version: '0.15.2'
2927

3028
- name: Install Dependencies
3129
run: |

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ################################################################################
22
# # Configuration and Variables
33
# ################################################################################
4-
ZIG ?= $(shell which zig || echo ~/.local/share/zig/0.15.1/zig)
4+
ZIG ?= $(shell which zig || echo ~/.local/share/zig/0.15.2/zig)
55
BUILD_TYPE ?= Debug
66
BUILD_OPTS = -Doptimize=$(BUILD_TYPE)
77
JOBS ?= $(shell nproc || echo 2)

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,38 @@
77
<h2>Ordered</h2>
88

99
[![Tests](https://img.shields.io/github/actions/workflow/status/CogitatorTech/ordered/tests.yml?label=tests&style=flat&labelColor=282c34&logo=github)](https://github.com/CogitatorTech/ordered/actions/workflows/tests.yml)
10-
[![Benchmarks](https://img.shields.io/github/actions/workflow/status/CogitatorTech/ordered/benches.yml?label=benches&style=flat&labelColor=282c34&logo=github)](https://github.com/CogitatorTech/ordered/actions/workflows/benches.yml)
10+
[![Benchmarks](https://img.shields.io/github/actions/workflow/status/CogitatorTech/ordered/benches.yml?label=benchmarks&style=flat&labelColor=282c34&logo=github)](https://github.com/CogitatorTech/ordered/actions/workflows/benches.yml)
1111
[![CodeFactor](https://img.shields.io/codefactor/grade/github/CogitatorTech/ordered?label=quality&style=flat&labelColor=282c34&logo=codefactor)](https://www.codefactor.io/repository/github/CogitatorTech/ordered)
12+
[![Zig Version](https://img.shields.io/badge/Zig-0.15.2-orange?logo=zig&labelColor=282c34)](https://ziglang.org/download/)
13+
<br>
1214
[![Docs](https://img.shields.io/badge/docs-view-blue?style=flat&labelColor=282c34&logo=read-the-docs)](https://CogitatorTech.github.io/ordered/)
1315
[![Examples](https://img.shields.io/badge/examples-view-green?style=flat&labelColor=282c34&logo=zig)](https://github.com/CogitatorTech/ordered/tree/main/examples)
14-
[![Zig Version](https://img.shields.io/badge/Zig-0.15.1-orange?logo=zig&labelColor=282c34)](https://ziglang.org/download/)
1516
[![Release](https://img.shields.io/github/release/CogitatorTech/ordered.svg?label=release&style=flat&labelColor=282c34&logo=github)](https://github.com/CogitatorTech/ordered/releases/latest)
1617
[![License](https://img.shields.io/badge/license-MIT-007ec6?label=license&style=flat&labelColor=282c34&logo=open-source-initiative)](https://github.com/CogitatorTech/ordered/blob/main/LICENSE)
1718

18-
A collection of data structures that keep data in order in pure Zig
19+
Pure Zig implementations of high-performance, memory-safe ordered data structures
1920

2021
</div>
2122

2223
---
2324

24-
Ordered is a Zig library that provides fast and efficient implementations of various popular data structures including
25+
Ordered is a Zig library that provides efficient implementations of various popular data structures including
2526
B-tree, skip list, trie, and red-black tree for Zig programming language.
2627

27-
### Supported Data Structures
28+
### Features
2829

29-
Currently supported data structures include:
30+
To be added.
3031

31-
- [B-tree](src/ordered/btree_map.zig): A self-balancing search tree where nodes can have many children.
32-
- [Sorted Set](src/ordered/sorted_set.zig): A data structure that stores a collection of unique elements in a consistently sorted order.
33-
- [Skip List](src/ordered/skip_list.zig): A probabilistic data structure that uses multiple linked lists to create "express lanes" for fast, tree-like search.
34-
- [Trie](src/ordered/trie.zig): A tree where paths from the root represent prefixes which makes it extremely fast for tasks like text autocomplete.
35-
- [Red-black Tree](src/ordered/red_black_tree.zig): A self-balancing binary search tree that uses node colors to guarantee efficient operations.
36-
- [Cartesian Tree](src/ordered/cartesian_tree.zig): A binary tree that uniquely combines a binary search tree property for its keys with a heap** property for its values.
32+
### Data Structures
3733

38-
| # | Data Structure | Build Complexity | Memory Complexity | Search Complexity |
39-
|---|----------------|------------------|-------------------|----------------------|
40-
| 1 | B-tree | $O(\log n)$ | $O(n)$ | $O(\log n)$ |
41-
| 2 | Cartesian tree | $O(\log n)$\* | $O(n)$ | $O(\log n)$\* |
42-
| 3 | Red-black tree | $O(\log n)$ | $O(n)$ | $O(\log n)$ |
43-
| 4 | Skip list | $O(\log n)$\* | $O(n)$ | $O(\log n)$\* |
44-
| 5 | Sorted set | $O(n)$ | $O(n)$ | $O(\log n)$ |
45-
| 6 | Trie | $O(m)$ | $O(n \cdot m)$ | $O(m)$ |
34+
| Data Structure | Build Complexity | Memory Complexity | Search Complexity |
35+
|------------------------------------------------------------------------|------------------|-------------------|-------------------|
36+
| [B-tree](https://en.wikipedia.org/wiki/B-tree) | $O(\log n)$ | $O(n)$ | $O(\log n)$ |
37+
| [Cartesian tree](https://en.wikipedia.org/wiki/Cartesian_tree) | $O(\log n)$\* | $O(n)$ | $O(\log n)$\* |
38+
| [Red-black tree](https://en.wikipedia.org/wiki/Red%E2%80%93black_tree) | $O(\log n)$ | $O(n)$ | $O(\log n)$ |
39+
| [Skip list](https://en.wikipedia.org/wiki/Skip_list) | $O(\log n)$\* | $O(n)$ | $O(\log n)$\* |
40+
| Sorted set | $O(n)$ | $O(n)$ | $O(\log n)$ |
41+
| [Trie](https://en.wikipedia.org/wiki/Trie) | $O(m)$ | $O(n \cdot m)$ | $O(m)$ |
4642

4743
- $n$: number of stored elements
4844
- $m$: maximum length of a key
@@ -72,6 +68,10 @@ and view in a web browser.
7268

7369
Check out the [examples](examples) directory for example usages of Ordered.
7470

71+
### Benchmarks
72+
73+
To be added.
74+
7575
---
7676

7777
### Contributing

benches/b2_sorted_set.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn benchmarkAdd(allocator: std.mem.Allocator, size: usize) !void {
3232

3333
var i: i32 = 0;
3434
while (i < size) : (i += 1) {
35-
try set.add(i);
35+
_ = try set.put(i);
3636
}
3737

3838
const elapsed = timer.read() - start;
@@ -51,7 +51,7 @@ fn benchmarkContains(allocator: std.mem.Allocator, size: usize) !void {
5151

5252
var i: i32 = 0;
5353
while (i < size) : (i += 1) {
54-
try set.add(i);
54+
_ = try set.put(i);
5555
}
5656

5757
var timer = try Timer.start();
@@ -80,7 +80,7 @@ fn benchmarkRemove(allocator: std.mem.Allocator, size: usize) !void {
8080

8181
var i: i32 = 0;
8282
while (i < size) : (i += 1) {
83-
try set.add(i);
83+
_ = try set.put(i);
8484
}
8585

8686
var timer = try Timer.start();

0 commit comments

Comments
 (0)