swisstable 0.2.0
D port of Swiss Tables
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Swiss Tables in D
D port of abseil's Swiss Tables.
Install
Use dub to add it as a dependency:
% dub install swisstable
Usage
Map
Replace built-in AA with swisstable.Map
.
import std.conv;
import std.stdio;
import swisstable.map;
void main()
{
auto map = Map!(int, string)();
foreach (i; 0..10)
map[i] = text("value", i);
auto p = 5 in map; // map[5] also supported
if (p)
*p = "new value";
map.remove(2);
foreach (e; map.byKeyValue())
writeln("key: ", e.key, ", value: ", e.value);
}
Set
import std.stdio;
import swisstable.set;
void main()
{
auto set = Set!(int)();
foreach (i; 0..10)
set.insert(i);
if (5 in set)
// do something
set.remove([2, 4]);
foreach (ref k; set.byKey())
writeln("key: ", k);
}
TODO
- Support Hasher object if needed
- Use LDC feature for performance optimization
- Improve internal data structure, e.g. remove Control.Sentinel
Links
Original implementation by C++
Use rapidhash for string/integer/pointer hashing in LDC compiler
Copyright
Copyright (c) 2024- Masahiro Nakagawa
License
Library code are distributed under the Apache License, Version 2.0. Benchmark code are Boost License because these code are copied from druntime's benchmark.
- 0.2.0 released 5 months ago
- repeatedly/swisstabled
- github.com/repeatedly/swisstabled
- Apache-2.0
- Copyright (c) 2024, Masahiro Nakagawa
- Authors:
- Dependencies:
- none
- Versions:
-
0.2.0 2024-Jul-15 0.1.0 2024-Jul-08 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
2 downloads total
-
- Score:
- 0.7
- Short URL:
- swisstable.dub.pm