Files
solstice/tests/generics.sols
2026-04-14 09:21:30 +10:00

47 lines
734 B
Plaintext

struct Hash {
protected hashstr = ""
}
struct Person {
age = 0
name = ""
constructor(int age, string name) {
self.age = age
self.name = name
}
as Hash {
// hash the Person here
}
}
struct HashTable<Key can Hash, Value> {
private ptr = 0
protected size = 0
private capacity = 0
def find(Key key) {
hash = key as Hash
// find in table using hash
}
def set(Key key, Value value) {
hash = key as Hash
// store Value in the table
}
constructor() {
// malloc the pointer and set up hash information
}
duplicator {
// copy all contents
}
destructor {
// free the ptr
}
}