Preliminary implementation of a hashmap, unfinished

Missing features:
  * keys other than strings
  * more than 8 values in the hashmap
  * growing a map when needed
  * initial size hint
  * delete(m, key)
  * iterators (for range)
  * initializing global maps
  * ...more?
This commit is contained in:
Ayke van Laethem
2018-08-22 04:50:24 +02:00
parent 8fb9cd4e23
commit 3a6ef38041
5 changed files with 290 additions and 21 deletions
+7
View File
@@ -23,6 +23,9 @@ func main() {
println("sumrange(100) =", sumrange(100))
println("strlen foo:", strlen("foo"))
m := map[string]int{"answer": 42, "foo": 3}
readMap(m, "answer")
foo := []int{1, 2, 4, 5}
println("len/cap foo:", len(foo), cap(foo))
println("foo[3]:", foo[3])
@@ -46,6 +49,10 @@ func runFunc(f func(int), arg int) {
f(arg)
}
func readMap(m map[string]int, key string) {
println("map read:", key, "=", m[key])
}
func hello(n int) {
println("hello from function pointer:", n)
}