zetzit / zz

πŸΊπŸ™ ZetZ a zymbolic verifier and tranzpiler to bare metal C
MIT License
1.6k stars 52 forks source link

hashmap #107

Closed aep closed 4 years ago

aep commented 4 years ago

we finally have a hashmap. this implements the minimum viable functions insert/remove/get/iter using the new void tail duck typing mechanism.

insert is implemented as both owned and borrowed keys and values. users can decide if they want to copy the k/v into the maps memory pool, or just store a reference which needs to be valid for the lifetime of the map.

additionally this change implements autocast from slice to void tail pointers, for convenient duck typing into generic containers.

here's a usage example

  new+1000 t = map::make();
  t.insert_oo("bob", "uncle");
  log::info("%s", t.borrow("bob"));