aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-21 15:43:59 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-21 15:43:59 -0400
commit71f73d8b3ce63f9a3685bc1a1686ef4fab3294a6 (patch)
tree99fe1309fa4d24609867dcc62859caed909a76d9 /src/stdlib
parentf5612e38183dc20d18f207f8ab055574a4d93ad0 (diff)
Deprecate sets
Diffstat (limited to 'src/stdlib')
-rw-r--r--src/stdlib/tables.c12
-rw-r--r--src/stdlib/tables.h20
2 files changed, 9 insertions, 23 deletions
diff --git a/src/stdlib/tables.c b/src/stdlib/tables.c
index 974e3542..7d5ff4ef 100644
--- a/src/stdlib/tables.c
+++ b/src/stdlib/tables.c
@@ -579,9 +579,9 @@ Table_t Table$from_entries(List_t entries, const TypeInfo_t *type) {
return t;
}
-// Overlap is "set intersection" in formal terms
+// And is "set intersection" in formal terms
public
-Table_t Table$overlap(Table_t a, Table_t b, const TypeInfo_t *type) {
+Table_t Table$and(Table_t a, Table_t b, const TypeInfo_t *type) {
// Return a table such that t[k]==a[k] for all k such that a.has(k), b.has(k), and a[k]==b[k]
Table_t result = {};
const size_t offset = value_offset(type);
@@ -597,9 +597,9 @@ Table_t Table$overlap(Table_t a, Table_t b, const TypeInfo_t *type) {
return result;
}
-// With is "set union" in formal terms
+// Or is "set union" in formal terms
public
-Table_t Table$with(Table_t a, Table_t b, const TypeInfo_t *type) {
+Table_t Table$or(Table_t a, Table_t b, const TypeInfo_t *type) {
// return a table such that t[k]==b[k] for all k such that b.has(k), and t[k]==a[k] for all k such that a.has(k) and
// not b.has(k)
Table_t result = {};
@@ -640,9 +640,9 @@ Table_t Table$xor(Table_t a, Table_t b, const TypeInfo_t *type) {
return result;
}
-// Without is "set difference" in formal terms
+// Minus is "set difference" in formal terms
public
-Table_t Table$without(Table_t a, Table_t b, const TypeInfo_t *type) {
+Table_t Table$minus(Table_t a, Table_t b, const TypeInfo_t *type) {
// Return a table such that t[k]==a[k] for all k such that not b.has(k) or b[k] != a[k]
Table_t result = {};
const size_t offset = value_offset(type);
diff --git a/src/stdlib/tables.h b/src/stdlib/tables.h
index 129aa5ec..4364530a 100644
--- a/src/stdlib/tables.h
+++ b/src/stdlib/tables.h
@@ -27,18 +27,6 @@
table.fallback = fb; \
table; \
})
-#define Set(item_t, item_info, N, ...) \
- ({ \
- item_t ents[N] = {__VA_ARGS__}; \
- Table_t set = Table$from_entries( \
- (List_t){ \
- .data = memcpy(GC_MALLOC(sizeof(ents)), ents, sizeof(ents)), \
- .length = sizeof(ents) / sizeof(ents[0]), \
- .stride = (void *)&ents[1] - (void *)&ents[0], \
- }, \
- Set$info(item_info)); \
- set; \
- })
Table_t Table$from_entries(List_t entries, const TypeInfo_t *type);
void *Table$get(Table_t t, const void *key, const TypeInfo_t *type);
@@ -103,13 +91,11 @@ void Table$remove(Table_t *t, const void *key, const TypeInfo_t *type);
Table$remove(t, &k, type); \
})
-Table_t Table$overlap(Table_t a, Table_t b, const TypeInfo_t *type);
-Table_t Table$with(Table_t a, Table_t b, const TypeInfo_t *type);
-Table_t Table$without(Table_t a, Table_t b, const TypeInfo_t *type);
+Table_t Table$and(Table_t a, Table_t b, const TypeInfo_t *type);
+Table_t Table$or(Table_t a, Table_t b, const TypeInfo_t *type);
+Table_t Table$minus(Table_t a, Table_t b, const TypeInfo_t *type);
Table_t Table$xor(Table_t a, Table_t b, const TypeInfo_t *type);
Table_t Table$with_fallback(Table_t t, OptionalTable_t fallback);
-PUREFUNC bool Table$is_subset_of(Table_t a, Table_t b, bool strict, const TypeInfo_t *type);
-PUREFUNC bool Table$is_superset_of(Table_t a, Table_t b, bool strict, const TypeInfo_t *type);
void Table$clear(Table_t *t);
Table_t Table$sorted(Table_t t, const TypeInfo_t *type);