Esempio n. 1
0
 public static bool remove(LuaMap map, object key)
 {
     if (key != null)
     {
         return(map.map.Remove(key));
     }
     return(false);
 }
Esempio n. 2
0
        public static LuaMap merge(LuaMap map1, LuaMap map2, Func <object, object, LuaResult> func)
        {
            Dictionary <object, object> map = new Dictionary <object, object>(map1.map);

            foreach (KeyValuePair <object, object> entry in map2.map)
            {
                if (func != null)
                {
                    object value;
                    if (map.TryGetValue(entry.Key, out value))
                    {
                        LuaResult res = func(value, entry.Value);
                        map[entry.Key] = res[0];
                        continue;
                    }
                }
                map[entry.Key] = entry.Value;
            }
            return(new LuaMap(map));
        }
Esempio n. 3
0
        public static LuaMap diff(LuaMap map1, LuaMap map2)
        {
            Dictionary <object, object> map = new Dictionary <object, object>(map1.map.Count + map2.map.Count);

            foreach (KeyValuePair <object, object> entry in map1.map)
            {
                if (!map2.map.ContainsKey(entry.Key))
                {
                    map[entry.Key] = entry.Value;
                }
            }

            foreach (KeyValuePair <object, object> entry in map2.map)
            {
                if (!map1.map.ContainsKey(entry.Key))
                {
                    map[entry.Key] = entry.Value;
                }
            }
            return(new LuaMap(map));
        }
Esempio n. 4
0
        public static LuaMap diff(LuaMap map1, LuaMap map2)
        {
            Dictionary<object, object> map = new Dictionary<object, object>(map1.map.Count + map2.map.Count);

            foreach (KeyValuePair<object, object> entry in map1.map)
            {
                if (!map2.map.ContainsKey(entry.Key))
                {
                    map[entry.Key] = entry.Value;
                }
            }

            foreach (KeyValuePair<object, object> entry in map2.map)
            {
                if (!map1.map.ContainsKey(entry.Key))
                {
                    map[entry.Key] = entry.Value;
                }
            }
            return new LuaMap(map);
        }
Esempio n. 5
0
 public static LuaMap clone(LuaMap map)
 {
     return(new LuaMap(new Dictionary <object, object>(map.map)));
 }
Esempio n. 6
0
 public static int size(LuaMap map)
 {
     return(map.map.Count);
 }
Esempio n. 7
0
        public static Func <object> values(LuaMap map)
        {
            LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());

            return(new Func <object>(iter.NextValue));
        }
Esempio n. 8
0
        public static Func <object[]> pairs(LuaMap map)
        {
            LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());

            return(new Func <object[]>(iter.NextPair));
        }
Esempio n. 9
0
 public static LuaMap merge(LuaMap map1, LuaMap map2, Func<object, object, LuaResult> func)
 {
     Dictionary<object, object> map = new Dictionary<object, object>(map1.map);
     foreach (KeyValuePair<object, object> entry in map2.map)
     {
         if (func != null)
         {
             object value;
             if (map.TryGetValue(entry.Key, out value))
             {
                 LuaResult res = func(value, entry.Value);
                 map[entry.Key] = res[0];
                 continue;
             }
         }
         map[entry.Key] = entry.Value;
     }
     return new LuaMap(map);
 }
Esempio n. 10
0
 public static Func<object> keys(LuaMap map)
 {
     LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());
     return new Func<object>(iter.NextKey);
 }
Esempio n. 11
0
 public static LuaMap clone(LuaMap map)
 {
     return new LuaMap(new Dictionary<object,object>(map.map));
 }
Esempio n. 12
0
 public static int size(LuaMap map)
 {
     return map.map.Count;
 }
Esempio n. 13
0
 public static bool remove(LuaMap map, object key)
 {
     if (key != null)
     {
         return map.map.Remove(key);
     }
     return false;
 }
Esempio n. 14
0
 public static Func<object[]> pairs(LuaMap map)
 {
     LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());
     return new Func<object[]>(iter.NextPair);
 }