Пример #1
0
 public static bool remove(LuaMap map, object key)
 {
     if (key != null)
     {
         return(map.map.Remove(key));
     }
     return(false);
 }
Пример #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));
        }
Пример #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));
        }
Пример #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);
        }
Пример #5
0
 public static LuaMap clone(LuaMap map)
 {
     return(new LuaMap(new Dictionary <object, object>(map.map)));
 }
Пример #6
0
 public static int size(LuaMap map)
 {
     return(map.map.Count);
 }
Пример #7
0
        public static Func <object> values(LuaMap map)
        {
            LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());

            return(new Func <object>(iter.NextValue));
        }
Пример #8
0
        public static Func <object[]> pairs(LuaMap map)
        {
            LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());

            return(new Func <object[]>(iter.NextPair));
        }
Пример #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);
 }
Пример #10
0
 public static Func<object> keys(LuaMap map)
 {
     LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());
     return new Func<object>(iter.NextKey);
 }
Пример #11
0
 public static LuaMap clone(LuaMap map)
 {
     return new LuaMap(new Dictionary<object,object>(map.map));
 }
Пример #12
0
 public static int size(LuaMap map)
 {
     return map.map.Count;
 }
Пример #13
0
 public static bool remove(LuaMap map, object key)
 {
     if (key != null)
     {
         return map.map.Remove(key);
     }
     return false;
 }
Пример #14
0
 public static Func<object[]> pairs(LuaMap map)
 {
     LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());
     return new Func<object[]>(iter.NextPair);
 }