most of hash map - have to commit fix for unify type first

This commit is contained in:
Nathan Braswell
2016-04-20 16:09:26 -04:00
parent 8d0996fb47
commit 2cd43e5a21
7 changed files with 155 additions and 6 deletions

View File

@@ -10,3 +10,15 @@ Lookie, a map!
What I get for not testing different types
key: 7, value: Lookie, a map!
key: 30, value: we'll look for for_each too
3
2
1
3
20
2
30
4
Lookie, a map!
What I get for not testing different types
key: 30, value: we'll look for for_each too
key: 7, value: Lookie, a map!

View File

@@ -1,8 +1,8 @@
import io:*
import map:*
import hash_map:*
fun main(): int {
var m = map(3,1)
fun test_map<T,V>(m: ref T, mapEx: ref V) {
m.set(2,2)
m.set(1,3)
println(m[1])
@@ -16,12 +16,22 @@ fun main(): int {
println(m[2])
println(m[6])
println(m[3])
var mapEx = map(7, "Lookie, a map!")
mapEx[20] = "What I get for not testing different types"
mapEx[30] = "we'll look for for_each too"
println(mapEx[7])
println(mapEx[20])
mapEx.remove(20)
mapEx.for_each(fun(key:int, value:*char) { print("key: "); print(key); print(", value: "); println(value); })
}
fun main(): int {
var m1 = map(3,1)
var mapEx1 = map(7, "Lookie, a map!")
test_map(m1, mapEx1)
var m2 = hash_map(3,1)
var mapEx2 = hash_map(7, "Lookie, a map!")
test_map(m2, mapEx2)
/*println(m2.data.size)*/
/*println(m2.data[1].keys.size)*/
/*println(mapEx2.data.size)*/
return 0
}