You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
libdsc is a free and open-source C library featuring generic reimplementations of containers provided by the C++ Standard Library.
13
19
14
20
## Features
15
21
16
-
`libdsc` implements the following containers:
22
+
libdsc currently reimplements the following containers:
23
+
24
+
### Sequence containers
25
+
26
+
-`std::vector`
27
+
28
+
-`std::forward_list`
29
+
30
+
-`std::list`
31
+
32
+
### Unordered associative containers
17
33
18
-
-`vector`: dynamically-sized array
19
-
-`forward_list`: singly-linked list
20
-
-`list`: doubly-linked list
21
-
-`stack`: LIFO container
22
-
-`queue`: FIFO container
23
-
-`unordered_map`: hash table for key-value pairs
24
-
-`unordered_set`: hash table for unique elements
34
+
-`std::unordered_map`
25
35
26
-
All containers are:
36
+
-`std::unordered_set`
27
37
28
-
- Generic (can store any data type)
29
-
- Memory safe (with proper error handling)
30
-
- Thoroughly tested
31
-
- Benchmarked against C++ Standard Library counterparts
38
+
### Container adaptors
39
+
40
+
-`std::stack`
41
+
42
+
-`std::queue`
43
+
44
+
All of these (re)implementations are generic (can store any data type), memory-safe, and benchmarked against their counterparts in the C++ Standard Library.
45
+
46
+
See [ROADMAP.md](ROADMAP.md) for a list of containers we plan to (re)implement in the future.
32
47
33
48
## Installing from source
34
49
@@ -50,75 +65,35 @@ sudo make install
50
65
This will install:
51
66
52
67
- Library files to `/usr/local/lib`
68
+
53
69
- Header files to `/usr/local/include/libdsc`
70
+
54
71
- CMake configuration files to `/usr/local/lib/cmake/libdsc`
55
72
56
73
## Installing from package
57
74
58
-
On Debian-based Linux distributions:
75
+
On Debian-based Linux distributions (e.g., Debian, Ubuntu, Linux Mint):
59
76
60
77
```bash
61
-
sudo dpkg -i libdsc-<current_version>.deb
78
+
sudo dpkg -i libdsc-*.deb
62
79
```
63
80
64
-
On RPM-based Linux distributions:
81
+
On RPM-based Linux distributions (e.g., Fedora, Red Hat):
65
82
66
83
```bash
67
84
68
85
```
69
86
70
87
## Usage
71
88
89
+
Simply include the relevant headers in your project, like so:
90
+
72
91
```c
73
92
#include<libdsc/vector.h>
74
93
#include<libdsc/list.h>
75
-
76
-
// Include other containers as needed ...
77
-
78
-
#include<stdio.h>
79
-
80
-
intmain(int argc, char *argv[]) {
81
-
// Create a vector of integers
82
-
dsc_vector *vec = vector_create(sizeof(int));
83
-
84
-
// Push some values
85
-
for (size_t i = 0; i < 5; ++i) {
86
-
vector_push_back(vec, &i);
87
-
}
88
-
89
-
// Access elements
90
-
for (size_t i = 0; i < vector_size(vec); ++i) {
91
-
int *value = (int *) vector_get(vec, i);
92
-
printf("%d ", *value);
93
-
}
94
-
95
-
// Clean up
96
-
vector_destroy(vec);
97
-
98
-
// Create a list of integers
99
-
dsc_list *list = list_create(sizeof(int));
100
-
101
-
// Push some values
102
-
for (size_t i = 0; i < 5; ++i) {
103
-
list_push_back(list, &i);
104
-
}
105
-
106
-
// Iterate through elements
107
-
list_node_t *current = list_begin(list);
108
-
while (current) {
109
-
int *value = (int *) current->data;
110
-
printf("%d ", *value);
111
-
current = current->next;
112
-
}
113
-
114
-
// Clean up
115
-
list_destroy(list);
116
-
117
-
return EXIT_SUCCESS;
118
-
}
119
94
```
120
95
121
-
More examples can be found in the `examples` directory.
96
+
Complete examples can be found in the `examples/` directory.
122
97
123
98
## Testing
124
99
@@ -133,6 +108,8 @@ ctest --output-on-failure
133
108
134
109
Google Benchmark is used to measure the performance of libdsc's containers against their equivalents in the C++ Standard Library. Benchmarks are run weekly automatically via GitHub Actions. You can also run the benchmarks locally:
135
110
111
+
Benchmarks are automatica
112
+
136
113
```bash
137
114
mkdir -p build
138
115
cd build
@@ -144,8 +121,8 @@ cd benchmarks
144
121
145
122
## Contributing
146
123
147
-
Please read [CONTRIBUTING.md](CONTRIBUTING.md) carefully before you attempt to make contributions to this project.
124
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) carefully before you attempt to make any contributions to this project.
148
125
149
126
## License
150
127
151
-
`libdsc` is licensed under the GPLv3. See [LICENSE](LICENSE) for details.
128
+
This project is licensed under the GPLv3. See [LICENSE](LICENSE) for details.
0 commit comments