Example #1
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o is RHash == false)
            {
                return(false);
            }
            RHash     ot = (RHash)o;
            Hashtable oh = ot.hash;

            if (hash.Count != oh.Count)
            {
                return(false);
            }
            lock (hash.SyncRoot)
            {
                foreach (DictionaryEntry ent in hash)
                {
                    if (oh.ContainsKey(ent.Key) == false)
                    {
                        return(false);
                    }
                    if (oh[ent.Key].Equals(ent.Value) == false)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Example #2
0
        static internal object s_create(RBasic r, params object[] args)
        {
            RHash hash;

            if (args.Length == 1 && args[0] is RHash)
            {
                hash = new RHash(r.ruby, ((RHash)args[0]), (RMetaObject)r);
                return(hash);
            }
            if (args.Length % 2 != 0)
            {
                throw new eArgError("odd number args for Hash");
            }
            hash = new RHash(r.ruby, (RMetaObject)r);
            for (int i = 0; i < args.Length; i += 2)
            {
                hash[args[i]] = args[i + 1];
            }
            return(hash);
        }
Example #3
0
 public RHash(NetRuby rb, RHash org, RMetaObject meta) :
     base(rb, meta)
 {
     hash = (Hashtable)org.hash.Clone();
     ifnone = null;
 }
Example #4
0
 static internal object s_create(RBasic r, params object[] args)
 {
     RHash hash;
     if (args.Length == 1 && args[0] is RHash)
     {
         hash = new RHash(r.ruby, ((RHash)args[0]), (RMetaObject)r);
         return hash;
     }
     if (args.Length % 2 != 0)
     {
         throw new eArgError("odd number args for Hash");
     }
     hash = new RHash(r.ruby, (RMetaObject)r);
     for (int i = 0; i < args.Length; i += 2)
     {
         hash[args[i]] = args[i + 1];
     }
     return hash;
 }
Example #5
0
 static internal object s_new(RBasic r, params object[] args)
 {
     RHash hash = new RHash(r.ruby, (RMetaObject)r);
     r.ruby.CallInit(hash, args);
     return hash;
 }
Example #6
0
        static internal object aref(RBasic r, params object[] args)
        {
            RHash h = (RHash)r;

            return(h[args[0]]);
        }
Example #7
0
 public RHash(NetRuby rb, RHash org, RMetaObject meta) :
     base(rb, meta)
 {
     hash   = (Hashtable)org.hash.Clone();
     ifnone = null;
 }