From 54bcbe0708799bac1469b9cfbd8272bfb453f3f2 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 25 Jun 2019 21:22:46 +0200 Subject: [PATCH] remove smap.v, it was not supposed to be released --- builtin/smap.v | 101 ------------------------------------------------ compiler/main.v | 1 - 2 files changed, 102 deletions(-) delete mode 100644 builtin/smap.v diff --git a/builtin/smap.v b/builtin/smap.v deleted file mode 100644 index 455cd86aed..0000000000 --- a/builtin/smap.v +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2019 Alexander Medvednikov. All rights reserved. -// Use of this source code is governed by an MIT license -// that can be found in the LICENSE file. - -module builtin - -struct Entry2 { - key string - val string -} - -struct smap { - entries []Entry2 - is_sorted bool -} - -fn new_smap() smap { - res := smap{} - return res -} - -fn (m mut smap) set(key string, val string) { - /* - for i := 0; i < m.entries.len; i++ { - entry := m.entries[i] - if entry.key == key { - e := Entry2{key: key, val: val} - m.entries[i] = e - return - } - } -*/ - e := Entry2{key: key, val: val} - m.entries << e -} - -fn (m smap) get(key string) string { - if m.is_sorted { - return m.bs(key, 0, m.entries.len) - } - for i := 0; i < m.entries.len; i++ { - entry := m.entries[i] - if entry.key == key { - return entry.val - } - } - return '' -} - -fn (m smap) bs(query string, start, end int) string { - mid := start + ((end - start) / 2) - if end - start == 0 { - last := m.entries[end] - return last.val - } - if end - start == 1 { - first := m.entries[start] - return first.val - } - if mid >= m.entries.len { - return '' - } - mid_msg := m.entries[mid] - if query < mid_msg.key { - return m.bs(query, start, mid) - } - return m.bs(query, mid, end) -} - -fn compare_smap(a, b *Entry2) int { - if a.key < b.key { - return -1 - } - if a.key > b.key { - return 1 - } - return 0 -} - -fn (m mut smap) sort() { - m.entries.sort_with_compare(compare_smap) - m.is_sorted = true -} - -fn (m smap) free() { - // m.entries.free() -} - -fn (m smap) str() string { - if m.entries.len == 0 { - return '{}' - } - // TODO use bytes buffer - mut s := '{\n' - for entry in m.entries { - s += ' "$entry.key" => "$entry.val"\n' - } - s += '}' - return s -} - diff --git a/compiler/main.v b/compiler/main.v index 00d5e6166b..04a7e894eb 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -756,7 +756,6 @@ fn new_v(args[]string) *V { 'int.v', 'utf8.v', 'map.v', - 'smap.v', 'option.v', 'string_builder.v', ]