v/vlib/builtin/js/map.v

68 lines
1.2 KiB
V
Raw Normal View History

2020-02-03 05:00:36 +01:00
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
2019-09-14 22:48:30 +02:00
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module builtin
import strings
2019-10-24 21:58:01 +02:00
pub struct map {
2019-09-14 22:48:30 +02:00
obj voidptr
}
//fn (m mut map) insert(n mut mapnode, key string, val voidptr) {
//}
//////fn (n & mapnode) find(key string, out voidptr, element_size int) bool{
//return false
//}
// same as `find`, but doesn't return a value. Used by `exists`
//fn (n & mapnode) find2(key string, element_size int) bool{
//return false
//}
//fn preorder_keys(node &mapnode, keys mut []string, key_i int) int {
//return 0
//}
pub fn (m mut map) keys() []string {
return ['']
}
fn (m map) get(key string, out voidptr) bool {
return false
}
pub fn (m mut map) delete(key string) {
}
2019-10-14 06:08:02 +02:00
fn (m map) exists(key string) bool {
2019-09-14 22:48:30 +02:00
return false
}
pub fn (m map) print() {
println('<<<<<<<<')
println('>>>>>>>>>>')
}
pub fn (m map) free() {
// C.free(m.table)
// C.free(m.keys_table)
}
pub fn (m map_string) str() string {
/*
if m.size == 0 {
return '{}'
}
*/
mut sb := strings.new_builder(50)
sb.writeln('{')
for key, val in m {
//sb.writeln(' "$key" => "$val"')
}
sb.writeln('}')
return sb.str()
}