示例#1
0
文件: Hash.cs 项目: toshok/shelisp
        public Hash(L l, Shelisp.Object test, Shelisp.Object weakness, Shelisp.Object size, Shelisp.Object rehash_size, Shelisp.Object rehash_threshold)
        {
            this.l = l;
            this.test = test;
            this.weakness = weakness;
            this.size = size;
            this.rehash_size = size;
            this.rehash_threshold = rehash_threshold;

            this.count = 0;
            // map weakness to our enum
            if (L.NILP (weakness)) {
                weakness_ = Weakness.None;
            }
            else if (weakness.LispEq (L.Qt)) {
                weakness_ = Weakness.KeyAndValue;
            }
            else if (weakness.LispEq (L.Qkey)) {
                weakness_ = Weakness.Key;
            }
            else if (weakness.LispEq (L.Qvalue)) {
                weakness_ = Weakness.Value;
            }
            else if (weakness.LispEq (L.Qkey_or_value)) {
                weakness_ = Weakness.KeyOrValue;
            }
            else if (weakness.LispEq (L.Qkey_and_value)) {
                weakness_ = Weakness.KeyAndValue;
            }
            else
                throw new Exception (string.Format ("invalid weakness {0}", weakness));

            compare = null;
            // use a builtin comparison function for the builtin test types
            if (test.LispEq (L.intern ("eq"))) {
                compare = compare_eq;
            }
            else if (test.LispEq (L.intern ("eql"))) {
                compare = compare_eql;
            }
            else if (test.LispEqual (L.intern ("equal"))) {
                compare = compare_equal;
            }

            table = new Tuple<Shelisp.Object,Shelisp.Object>[(int)((Number)size).boxed];
        }