diff options
| author | Tyge Løvset <[email protected]> | 2022-05-24 21:12:56 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-05-24 21:12:56 +0200 |
| commit | ebc7316ac3859bc5e2f01c85bee86d6adea45898 (patch) | |
| tree | fb653c49e223cca40aea3fc2d734cd69b608b46d /examples/bits2.c | |
| parent | 966100106830f990bc3e1b40a5b5c39b64d5e9b0 (diff) | |
| download | STC-modified-ebc7316ac3859bc5e2f01c85bee86d6adea45898.tar.gz STC-modified-ebc7316ac3859bc5e2f01c85bee86d6adea45898.zip | |
API change: cbits now uses container pointers args in all member functions, except clone() ... for now. All containers may get same treatment! which will be a rather big API change. This was needed after testing fixed size cbits performance with pass-by-value: was very slow for large bitsets: now faster than std::bitset<>. Also reverted previous cbits_set_value(): much faster because it is branchless.
Diffstat (limited to 'examples/bits2.c')
| -rw-r--r-- | examples/bits2.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/examples/bits2.c b/examples/bits2.c index e9202efc..81e28d60 100644 --- a/examples/bits2.c +++ b/examples/bits2.c @@ -9,14 +9,14 @@ int main() {
Bits s1 = Bits_from("1110100110111");
- printf("size %" PRIuMAX "\n", Bits_size(s1));
+ printf("size %" PRIuMAX "\n", Bits_size(&s1));
char buf[256];
- Bits_to_str(s1, buf, 0, -1);
- printf("buf: %s: count=%" PRIuMAX "\n", buf, Bits_count(s1));
+ Bits_to_str(&s1, buf, 0, -1);
+ printf("buf: %s: count=%" PRIuMAX "\n", buf, Bits_count(&s1));
Bits_reset(&s1, 8);
- c_autobuf (str, char, Bits_size(s1) + 1)
- printf(" s1: %s\n", Bits_to_str(s1, str, 0, -1));
+ c_autobuf (str, char, Bits_size(&s1) + 1)
+ printf(" s1: %s\n", Bits_to_str(&s1, str, 0, -1));
Bits s2 = Bits_clone(s1);
@@ -24,19 +24,19 @@ int main() Bits_reset(&s2, 66);
Bits_reset(&s2, 67);
printf(" s2: ");
- c_forrange (i, Bits_size(s2))
- printf("%d", Bits_test(s2, i));
+ c_forrange (i, Bits_size(&s2))
+ printf("%d", Bits_test(&s2, i));
puts("");
printf("xor: ");
- Bits_xor(&s1, s2);
- c_forrange (i, Bits_size(s1))
- printf("%d", Bits_test(s1, i));
+ Bits_xor(&s1, &s2);
+ c_forrange (i, Bits_size(&s1))
+ printf("%d", Bits_test(&s1, i));
puts("");
printf("all: ");
Bits_set_pattern(&s1, 0x3333333333333333);
- c_forrange (i, Bits_size(s1))
- printf("%d", Bits_test(s1, i));
+ c_forrange (i, Bits_size(&s1))
+ printf("%d", Bits_test(&s1, i));
puts("");
}
|
